安全序列
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
const int N = 1e6 + 10,mod = 1e9 + 7;
int n, k;
int dp[N];
void solve(){
cin >> n >> k;
dp[1] = 2;
for(int i = 2; i <= n ; i ++){
if(i-k-1>=1) dp[i] = (dp[i-1] + dp[i-k-1])%mod;
else dp[i] = (dp[i-1] + 1) % mod;//如果i-k-1<1,如果选可以让前面全为0,最后加1
}
cout << dp[n];
}
signed main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int _ = 1;
//cin >> _;
while(_--) solve();
return 0;
}