Inspired by the Fibonacci sequence $F_0 = 0, F_1 = 1, F_n = F_{n-1} + F_{n-2} \mbox{\, for \,} n \ge 2$, Xavier defined his own sequence of numbers: $$X_0 = 0, X_1 = 1, X_n = X_{X_{n-1}} + X_{X_{n-2}} \mbox{\, for \,} n \ge 2 .$$ Max also wanted his own sequence of numbers, so he modified Xavier’s definition a bit: $$M_0 = 1, M_1 = 0, M_n = M_{M_{n-1}} + M_{M_{n-2}} \mbox{\, for \,} n \ge 2 .$$ Can you compute the -th term of any of these two new sequences?
Input consists of several cases, each with a character
,
which is ‘X’ or ‘M’, and a natural
between 0 and
.
For each case, print or depending on .
Input
X 0 X 1 X 2 X 3 M 0 M 1 M 2 M 3
Output
0 1 1 2 1 0 1 1