#include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int INF = 1000 * 1000 * 1000;
const long long LINF = (long long)INF * INF;
long long adj[120][120];
long long n, m;
long long res[120][120];
long long tmp[120][120];
void mat_mul(long long a[120][120], long long b[120][120],
             long long res[120][120]) {
  for (int i = (1); i < (m + 1); i++) {
    for (int j = (1); j < (m + 1); j++) {
      res[i][j] = 0;
      for (int k = (1); k < (m + 1); k++) {
        res[i][j] = (res[i][j] + a[i][k] * b[k][j] % mod) % mod;
      }
    }
  }
}
void mat_pow(long long a[120][120], long long b) {
  if (b == 1) {
    for (int i = (1); i < (m + 1); i++) {
      copy(a[i] + 1, a[i] + m + 1, res[i] + 1);
    }
    return;
  }
  mat_pow(a, b / 2);
  mat_mul(res, res, tmp);
  for (int i = (1); i < (m + 1); i++) {
    copy(tmp[i] + 1, tmp[i] + m + 1, res[i] + 1);
  }
  if (b % 2 == 1) {
    mat_mul(tmp, a, res);
  }
}
int32_t main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  adj[1][1] = 1;
  adj[m][1] = 1;
  for (int i = (1); i < (m); i++) {
    adj[i][i + 1] = 1;
  }
  mat_pow(adj, n);
  cout << res[1][1] << '\n';
  return 0;
}
