n, l = input().split() n = int(n) l = int(l) mod = 1000000007 if n < l: print(pow(2, n - 1, mod)) exit() a = [None] * (n + 1) a[0] = 1 for i in range(1, l): a[i] = pow(2, i - 1, mod) s = 0 for i in range(l): s += a[i] s %= mod for i in range(l, n + 1): a[i] = s s -= a[i - l] s += a[i] s %= mod print(a[n])