문제
In this problem we consider three types of operations that can be applied to any
I(t) : Reversest .
R(t, D) : Rotatest to the rightD positions, for some positive integerD < |t| . That is, for each0 ≤ i < |t| , the character at position(i+D) \bmod |t| inR(t, D) is the character at positioni int .
L(t, D) : Analogous toR(t, D) , but rotatest to the left instead of to the right.
For example,
When a list of the above operations is applied to a string, it is done sequentially in list order. That is, the first operation of the list is applied to the original string, the second operation is applied to the result after having applied the first operation, the third operation is applied to the result after having applied the first two operations, and so on.
You are given a string
Consider for instance
입력
The first line contains a string
The second line contains an integer
Operations are described in the next
출력
Output a single line with an integer indicating the requested number of pairs.
예제 #1
pda
2
R 2
L 2
1
예제 #2
aaa
4
R 1
I
I
R 1
10
예제 #3
caso
6
L 1
I
I
R 1
I
I
4