n, l = map(int, input().split()) mod = 10**9 + 7 if n < l: print(pow(2, n - 1, mod)) exit() DP = [0 for _ in range(n + 1)] DP[0] = 1 for i in range(1, l): DP[i] = pow(2, i - 1, mod) s = 0 for i in range(l): s += DP[i] s %= mod for i in range(l, n + 1): DP[i] = s s -= DP[i - l] s += DP[i] s %= mod print(DP[n])