class LazySegTree_RAQ: def __init__(self,init_val,segfunc,ide_ele): n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1<<(n-1).bit_length() self.tree = [ide_ele]*2*self.num self.lazy = [0]*2*self.num for i in range(n): self.tree[self.num+i] = init_val[i] for i in range(self.num-1,0,-1): self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1]) def gindex(self,l,r): l += self.num r += self.num lm = l>>(l&-l).bit_length() rm = r>>(r&-r).bit_length() while r>l: if l<=lm: yield l if r<=rm: yield r r >>= 1 l >>= 1 while l: yield l l >>= 1 def propagates(self,*ids): for i in reversed(ids): v = self.lazy[i] if v==0: continue self.lazy[i] = 0 self.lazy[2*i] += v self.lazy[2*i+1] += v self.tree[2*i] += v self.tree[2*i+1] += v def add(self,l,r,x): ids = self.gindex(l,r) l += self.num r += self.num while l>= 1 l >>= 1 for i in ids: self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1]) + self.lazy[i] def query(self,l,r): self.propagates(*self.gindex(l,r)) res = self.ide_ele l += self.num r += self.num while l>= 1 r >>= 1 return res #返す値 def segfunc(x, y): #return max(x, y) #return min(x, y) return (x+y)%(10**9+7) #return x*y #単位元 #ide_ele = -float('inf') #ide_ele = float('inf') ide_ele = 0 #ide_ele = 1 #update(l, r, x): 区間[l, r)の値にxを加算 #add(l, r): 区間[l, r)をsegfuncしたものを返す n,k=map(int,input().split()) dp=[0]*(n+1) dp[0]=1 seg = LazySegTree_RAQ(dp, segfunc, ide_ele) mod=10**9+7 for i in range(1,n+1): seg.add(i,min(i+k,n+1),seg.query(i-1,i)) print(seg.query(n,n+1))