N,L=map(int,input().split()) M=10**9+7 D=[pow(2,i,M) for i in range(L)] X=sum(D)%M for i in range(N-L):D+=[X];X+=X-D[-L-1];X%=M print(D[N-1])