N, M = map(int, input().split()) def power(base, exp, op=lambda x, y: x * y, ie=1): res = ie while exp: if exp & 1: res = op(res, base) base = op(base, base) exp >>= 1 return res def fibonacci(n, mod=1000000007): I = (1, 0, 0, 1) A = (1, 1, 1, 0) def mmul(x, y): x00, x01, x10, x11 = x y00, y01, y10, y11 = y z00 = (x00 * y00 + x01 * y10) % mod z01 = (x00 * y01 + x01 * y11) % mod z10 = (x10 * y00 + x11 * y10) % mod z11 = (x10 * y01 + x11 * y11) % mod return z00, z01, z10, z11 return power(A, n, mmul, I)[3] print(fibonacci(N, M))