N, M = map(int, input().split()) if N == 1: print(1) quit() pos = [] data = [list(range(1, N+1)), list(range(N, 0, -1))] idx = 0 while len(pos) < M+1: nex = data[idx].copy() nex = nex[:M+1 - len(pos)] pos += nex idx ^= 1 pos = pos + pos[:-1][::-1] MOD = 10**9 + 7 num = 10**6 + 1 frac = [1] * num inv_frac = [1] * num for i in range(2, num): frac[i] = (frac[i-1] * i) % MOD inv_frac[-1] = pow(frac[-1], MOD-2, MOD) for i in range(num-1, 0, -1): inv_frac[i-1] = (inv_frac[i] * i) % MOD def comb(n, r): if r < 0 or r > n: return 0 return (frac[n] * (inv_frac[n-r] * inv_frac[r])%MOD) % MOD ans = 0 if M%2 == 0: ans += comb(M, M//2) ans %= MOD for x in range(1, M+1): if pos[x] == 1 and (x+M)%2 == 0: # M回操作して +xとなる # => 表をa回、裏をM-a回とすると、a - (M-a) = x <=> 2a = x+M <=> a = (x+M)//2 a = (x + M) // 2 ans += comb(M, a) ans %= MOD if pos[-x] == 1 and (M-x)%2 == 0: # M回操作して -xとなる # => 表をa回、裏をM-a回とすると、a-(M-a) = -x <=> a = (M-x) // 2 a = (M - x) // 2 ans += comb(M, a) ans %= MOD print(ans)