#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9 + 7;
const int N = 110;
LL n, m;
struct mat{
LL a[N][N];
mat operator* (mat const &b) const {
mat res;
memset(res.a, 0, sizeof res.a);
for (int i = 0; i < m; i ++ )
for (int j = 0; j < m; j ++ )
for (int k = 0; k < m; k ++ )
res.a[i][j] = (res.a[i][j] + a[i][k] * b.a[k][j]) % mod;
return res;
}
};
void work(LL t) {
mat c, res;
memset(c.a, 0, sizeof c.a);
memset(res.a, 0, sizeof res.a);
c.a[0][0] = c.a[0][m - 1] = 1;
for (int i = 1; i < m; i ++ ) c.a[i][i - 1] = 1;
for (int i = 0; i < m; i ++ ) res.a[0][i] = 1;
while (t) {
if (t & 1) res = res * c;
c = c * c;
t >>= 1;
}
printf("%lld\n", res.a[0][0]);
}
int main() {
scanf("%lld%lld", &n, &m);
if (m > n) printf("1\n");
else work(n - m + 1);
return 0;
}