N,M = map(int,input().split())
dp = [0]*(N+1)
dp[0] = 1
for i in range(M):
  dp[a] = -1
k = 10**9+7
d = 1
if N == 1:
  print(1)
else:
  for i in range(1,N+1):
    if dp[i] == -1:
      continue
    elif i==1:
      dp[i] = 1
    elif i==2:
      dp1 = dp[i-1] if dp[i-1] != -1 else 0
      d += dp[1]
      dp[i] = d
    else:
      dp1 = dp[i-1] if dp[i-1] != -1 else 0
      dp3 = dp[i-3] if dp[i-3] != -1 else 0
      d = d-dp3+dp1
      dp[i] = d
  print(dp[N]%k)