#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000000 + 7;
long long n, m, dp[105];
struct Matrix {
  int x, y;
  long long a[105][105];
  Matrix(int x, int y) : x(x), y(y) { memset(a, 0, sizeof(a)); }
};
Matrix operator*(Matrix A, Matrix B) {
  Matrix C(A.x, B.y);
  for (int i = 1; i <= A.x; ++i) {
    for (int j = 1; j <= B.y; ++j) {
      for (int k = 1; k <= A.y; ++k) {
        C.a[i][j] = (C.a[i][j] + A.a[i][k] * B.a[k][j] % mod) % mod;
      }
    }
  }
  return C;
}
Matrix qpow(Matrix A, long long b) {
  Matrix E(A.x, A.y);
  for (int i = 1; i <= A.x; ++i) {
    E.a[i][i] = 1;
  }
  while (b) {
    if (b & 1) E = E * A;
    A = A * A;
    b >>= 1;
  }
  return E;
}
int main() {
  scanf("%lld%lld", &n, &m);
  if (n < m) {
    printf("1\n");
    return 0;
  }
  Matrix A(m, m);
  A.a[1][1] = A.a[m][1] = 1;
  for (int i = 1; i < m; ++i) {
    A.a[i][i + 1] = 1;
  }
  Matrix B(1, m);
  for (int i = 1; i <= m; ++i) {
    B.a[1][i] = 1;
  }
  B = B * qpow(A, n - m + 1);
  printf("%lld\n", B.a[1][1]);
  return 0;
}
