import sys sys.setrecursionlimit(5*10**6) n, m = map(int, input().split()) memo = {} def fib(n): if n < 2: return n elif not n in memo: memo[n] = fib(n-1) + fib(n-2) return memo[n] print(fib(n-1)%m) import sys sys.setrecursionlimit(5*10**6) n, m = map(int, input().split()) memo = {} def fib(n): if n < 2: return n elif not n in memo: memo[n] = fib(n-1) + fib(n-2) return memo[n] print(fib(n-1)%m)