#!/usr/bin/env python3 import numpy as np def powmod(f, n, mod): g = np.identity(3, dtype=np.uint64) for p in map(int, reversed(bin(n)[2 :])): if p: g = g * f % mod f = f * f % mod return g def solve(n, m): # \begin{pmatrix} F_{2i+1} \\ F_{2i} \\ \sum_{j \le i} F_{2j} \end{pmatrix} x = np.matrix([ 1, 0, 0 ], dtype=np.uint64).transpose() f = np.matrix([ [ 1, 1, 0 ], [ 1, 0, 0 ], [ 0, 0, 1 ], ], dtype=np.uint64) g = np.matrix([ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 1, 1 ], ], dtype=np.uint64) mod = 10 ** 9 + 7 return (powmod(g * powmod(f, m, mod) % mod, n, mod) * x % mod)[2, 0] print(solve(*map(int, input().split())))