Ordinary Ordinals

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Sets, sets, sets. Everything in math is just a set. Even the natural numbers can be represented as sets. For example, we can represent the the number 00 as the empty set \\{\\}. The number 11 can be represented as \\{\\{\\}\\}.

But what about 22? Consider ,\\{\\{\\},\\{\\{\\}\\}\\}, the set containing both the empty set and \\{\\{\\}\\}. This is a nice choice for 22 for two reasons: we have that 00 and 11 are elements of 22 and we also have that 00 and 11 are subsets of 22.

In general, for N>0N>0 we can represent NN as the set 0,1,,N1\\{0,1, \dots ,N-1\\} where we recursively apply the representations for 0,1,,N10,1, \dots ,N-1. For example: \begin{eqnarray\*} 3 & = & \\{ 0, 1, 2\\} \\\ & = & \\{ \\{ \\} , \\{ 0\\} , \\{ 0, 1\\} \\} \\\ & = & \\{ \\{ \\} , \\{ \\{ \\} \\} , \\{ \\{ \\}, \\{ 0\\} \\} \\} \\\ & = & \\{ \\{ \\} , \\{ \\{ \\} \\} , \\{ \\{ \\} , \\{ \\{ \\} \\} \\} \\} \end{eqnarray\*}

Thus, for each 0i\<N0≤i\<Nii is both a member of NN and a subset of NN. Another nice feature is the size of the set representing NN is also NN. But what is not so nice is the number of characters it takes to write such a set. Given a natural number N0N≥0, how many braces and commas are required to write out the set representing NN in the above manner?

More specifically, let f(N)f(N) be the number of bracket and comma characters required to write out the set representing NN. Since f(N)f(N) can be quite large, your job is to determine f(N)f(N) modulo some positive integer MM.

입력

Input consists of two integers NN (0N<2630≤N<2^{63}) and MM (1M<2311≤M<2^{31}) as described above.

출력

Display the value of f(N)f(N) reduced modulo MM. That is, the remainder that would be left if you divided f(N)f(N) by MM.