44. Glitched Pong

Time Limit: 2 seconds

Memory Limit: 256 MB

Rating: 900

Problem Statement

Gnop has recently been learning how to use pygame (a game engine using python), and to practise his skills he decided to recreate pong. However, the recreation did not go as successfully as Gnop had wanted - there is a bug where the Pong ball gets stuck at the edges of the screen. Gnop is devastated, but instead of solving the bug, Gnop decides to make this a feature and decides that a stuck ball means a draw for each player. For each player, the score string of the player is a string representing the results of each round. Each character of the string can be a: ‘W’, representing a win. A win causes the score of the winner to increase by $3$. ‘L’, representing a loss. A loss causes the score of the player to decrease by $1$. ‘D’, representing a draw. A draw causes the score of both players to increase by $1$. Gnop is supposed to store the score string for both players, but he forgot to do so in his program! Given the score string of player $A$, find the score string of player $B$ and hence calculate the final score of player $B$. *Note that a win by player $A$ means a loss for player $B$ and vice versa. Also, a draw by player $A$ means a draw for player $B$.

Input

On the first line, you are given the score string of player $A$. The length of this string does not exceed $3000$.

Output

Output the final score of player $B$.

Sample Cases
Sample Input 1:
LWD

Sample Output 1:
3


Sample Input 2:
WLDDL

Sample Output 2:
7


Sample Input 3:
WDDWDWLLDD

Sample Output 3:
8
Explanation

Not available for this problem.

Sources

KL Coding Cup March 2023 > Pong > Problem 2

Submit | Back