using System; class B { static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse); static (int, int) Read2() { var a = Read(); return (a[0], a[1]); } static void Main() => Console.WriteLine(Solve()); static object Solve() { var (n, m) = Read2(); return CreateSeqWithMod(n - 1, m)[^1]; } public static long[] CreateSeqWithMod(int nLast, long mod) { var a = new long[nLast + 1]; a[1] = 1; for (int i = 2; i <= nLast; i++) a[i] = (a[i - 1] + a[i - 2]) % mod; return a; } }