#Q222. 「一本通 6.5 例 2」Fibonacci 第 n 项

「一本通 6.5 例 2」Fibonacci 第 n 项

Description

Everyone knows the Fibonacci sequence, right? f1=1f_1=1, f2=1f_2=1, f3=2f_3=2, f4=3f_4=3, \dots, fn=fn1+fn2f_n=f_{n-1}+f_{n-2}.

Now the problem is simple: given nn and mm, compute fnmodmf_n \bmod m.

Input Format

Input nn and mm.

Output Format

Output fnmodmf_n \bmod m.

Sample 1

5 1000

5

Constraints & Hints

For 100%100\% of the data, 1n2×1091\le n \le 2\times 10^9, 1m109+101\le m \le 10^9+10.