#include <bits/stdc++.h>
using namespace std;
long long a[105][105], c[105][105], ans[105][105];
long long n, m;
void mult(long long a[105][105], long long b[105][105]) {
  long long i, j, k;
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) c[i][j] = 0;
  }
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) {
      for (long long k = 0; k < m; k++) {
        c[i][j] += (a[i][k] * b[k][j]);
        c[i][j] %= (1000 * 1000 * 1000 + 7);
      }
    }
  }
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) a[i][j] = c[i][j];
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  if (n < m) {
    cout << 1;
    return 0;
  }
  for (long long i = 1; i <= m - 1; i++) {
    a[i][i - 1] = 1;
  }
  a[0][0] = 1;
  a[0][m - 1] = 1;
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) {
      ans[i][j] = 0;
    }
    ans[i][i] = 1;
  }
  long long val = n - m + 1;
  while (val) {
    if (val & 1) mult(ans, a);
    mult(a, a);
    val >>= 1;
  }
  long long sum = 0;
  for (long long i = 0; i < m; i++) {
    sum += ans[0][i];
    sum %= (1000 * 1000 * 1000 + 7);
  }
  cout << sum << endl;
  return 0;
}
