ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

Contest is over

## B. Cube in a Cube in a Cube

Time limit: 0.5 second
Memory limit: 64 MB
Denis had a Rubik's cube covered with pretty patterns on his table. When Denis quit the room, Vadik took the cube and made a few rotations. But he got scared suddenly: what if Denis get angry about the broken patterns? Vadik wanted to restore the cube to the original state, but could not find a way.
Vadik heard somewhere that if one repeats a sequence of rotations again and again, one would get the original pattern at some point. Given this is true, it is possible to revert the cube until Denis returns. How many times does Vadik need to apply his sequence of rotations in order to revert the cube to the original state?

### Input

The description of rotations applied by Vadik in the form of a string consisting of letters “U”, “D”, “L”, “R”, “F” and “B” (upper or lower case). They mean rotations of top, bottom, left, right, front and back faces, respectively. Lowercase letters mean 90-degree clockwise rotations, uppercase letters mean 90-degree counterclockwise rotations. The string is not empty and its length does not exceed 105.

### Output

Output the number of times Vadik needs to apply his sequence of rotations in order to get the original pattern.

### Samples

inputoutput
```Ud
```
```3
```
```RRRR
```
```0
```
Problem Author: Grigoriy Nazarov
Problem Source: Ural SU Team.GOV Contest. Petrozavodsk Summer Session, August 2011
To submit the solution for this problem go to the Problem set: 1852. Cube in a Cube in a Cube