#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int> > v(101, vector<int>(101)), u(101, vector<int>(101));
vector<vector<int> > operator*(vector<vector<int> > a, vector<vector<int> > b) {
  vector<vector<int> > temp(101, vector<int>(101));
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 101; j++) {
      long long sum = 0;
      for (int k = 0; k < 101; k++) {
        sum = (sum + 1LL * a[i][k] * b[k][j]) % 1000000007;
      }
      temp[i][j] = sum;
    }
  }
  return temp;
}
vector<vector<int> > power(long long n) {
  vector<vector<int> > res(101, vector<int>(101));
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 101; j++) {
      if (i == j)
        res[i][i] = 1;
      else
        res[i][j] = 0;
    }
  }
  while (n) {
    if (n & 1) res = res * v;
    n >>= 1;
    v = v * v;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, m;
  cin >> n >> m;
  if (n < m) {
    cout << 1;
    return 0;
  }
  v[0][0] = 1;
  v[0][m - 1] = 1;
  for (int i = 1; i < m; i++) {
    v[i][i - 1] = 1;
  }
  u = power(n - m + 1);
  int ans = 0;
  for (int i = 0; i < m; i++) {
    ans = ans + u[0][i];
    ans %= 1000000007;
  }
  cout << ans;
}
