Welcome to ZOJ
 Problem Sets Information Select Problem Runs Ranklist
ZOJ Problem Set - 3050
Painting

Time Limit: 1 Second      Memory Limit: 32768 KB

When Vitta was a little girl, she had a dream, that is, to be an excellent painter! But as she entered university, she has no more time to do it. One day, to kill the boring time, she thinks up a game to play with Winsty. First, she picks a number, then she draws the LED representation (see the following picture for detail) of it on a paper, and writes a sequence of the drawing steps. At first, she puts her pen on the paper. If she moves up her pen, she will write a letter 'U'. The same it goes, 'D' for down, 'L' for left, 'R' for right. Besides, if she let her pen leave the paper, she will write a letter 'u', and when she puts it down again, she will write 'd'. She sends the entire sequence to Winsty, and let he guess the number she paints. But Vitta finds that Winsty replies so quickly, and finally she discovers the secret: Winsty wrote a program to solve it! Now Vitta wants the magical program too, and it is your turn to help her.

Input

One line for each case, the sequence constituted by letter 'UDLRud'. The length of the sequence is less and shorter than 50. We assume that:

1. The first 'u' is before the first 'd'. There's at least one 'd' between two 'u's, and vice versa.
2. The length of each move is the same.
3. Every sequence can match a number.
4. Every case only represents one number.
5. The length of each edge is the same and is an integer time of the length of each move.

Output

One line for each case, the resulting number.

Sample Input

```UULLDDDDRRUUUU
UuLdDRD
UU
```

Sample Output

```0
4
1
```

Author: WANG, Naiyan
Source: ZOJ Monthly, October 2008
Submit    Status