#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int M = 105;
int m;
struct matrix {
  long long a[M][M];
} X, T, I;
matrix mul(matrix A, matrix B) {
  matrix C;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) {
      C.a[i][j] = 0;
      for (int k = 0; k < m; k++)
        C.a[i][j] = (C.a[i][j] + A.a[i][k] * B.a[k][j]) % mod;
    }
  return C;
}
matrix fast_power(matrix A, long long n) {
  matrix R = I;
  for (; n; n >>= 1, A = mul(A, A))
    if (n & 1) R = mul(R, A);
  return R;
}
int main() {
  long long n;
  long long ans = 0;
  cin >> n >> m;
  if (n < m) {
    printf("1\n");
    return 0;
  }
  for (int i = 0; i <= m; i++)
    for (int j = 0; j <= m; j++)
      if (i == j)
        I.a[i][j] = 1;
      else
        I.a[i][j] = 0;
  X.a[0][0] = 1;
  X.a[0][m - 1] = 1;
  for (int i = 0; i < m - 1; i++) X.a[i + 1][i] = 1;
  T = fast_power(X, n - m + 1);
  for (int i = 0; i < m; i++) ans = (ans + T.a[0][i]) % mod;
  cout << ans << endl;
}
