Description
Rubik's Cube is one of the most popular toys in the world. The job of recovering 6 faces is interesting. Now it can be solved by computer very efficiently, but this time I won't give you such a hard assignment.
A Rubik's Cube player may find that any series of certain operations on a Cube is periodic, which means that given a series of operations, if performed on a recovered cube successively for a certain times, the cube will be recovered again. The minimum number of times required is called the period of that series of operations.
Now you are asked to calculate the period of some given series of operations.
Input
Input terminates with EOF.
Each case has a line describing the series of operations.
Any series is composed of unit operations of the following 18 ones:
U U' U2 R R' R2 F F' F2
D D' D2 L L' L2 B B' B2
Any two operations is separated by a space.
Any series has no more than 100 operations and no less than 1 operation.
The function of the above operation is explained in the following figure:
Output
For each case output one number indicating the period in one line.
Sample Input
F
R2 R2
U R' U' R
Sample Output
4
1
6
HINT
1. Before scrambling, each face of the cube has a unique color.
2. The cube is recovered when any face is composed of only one color.
输入
输入终止与EOF分析。
每个案件有一个行描述了一系列的行动。
任何系列组成单位业务的下列18个的:
U U' U2 R R' R2 F F' F2
D D' D2 L L' L2 B B' B2
任何两个行动以一个空格隔开。
没有任何系列100多个业务和不低于1作业。
的功能,上述行动中解释如下图: