Statement
Statement language
A qubit is in one of the following four states.
- : the state
- : the state
- : a sum of and
- : a difference of and
There are three kinds of gates: H, X, and Z. They transform a qubit as follows.
H: swaps with , and swaps with .X: swaps with , and leaves and unchanged.
A circuit contains gates in a line. For an interval , a qubit passes through gates in this order.
Count the intervals for which each of the four states returns to its initial state after passing through the interval.
Input
The input is given in the following format:
Output
For each case, print the number of intervals satisfying the condition on one line.
Constraints
- .
- .
- is a string of length consisting only of , , and .
Subtasks
Samples
Input
1
4
HHZZ
Output
3