#include <bits/stdc++.h>
using namespace std;
const int MAXM = 100;
const long long MOD = 1e9 + 7;
long long A[MAXM + 2][MAXM + 2];
long long RET[MAXM + 2][MAXM + 2];
long long temp[MAXM + 2][MAXM + 2];
long long M;
void multiplica(long long B[MAXM + 2][MAXM + 2],
                long long C[MAXM + 2][MAXM + 2]) {
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < M; ++j) {
      temp[i][j] = 0;
      for (int k = 0; k < M; ++k) {
        long long aux = (B[i][k] * C[k][j]) % MOD;
        temp[i][j] = (temp[i][j] + aux) % MOD;
      }
    }
  }
}
void copia(long long fuente[MAXM + 2][MAXM + 2],
           long long destino[MAXM + 2][MAXM + 2]) {
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < M; ++j) {
      destino[i][j] = fuente[i][j];
    }
  }
}
void imprime_matriz(long long mat[MAXM + 2][MAXM + 2]) {
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < M; ++j) {
      cout << mat[i][j] << " ";
    }
    cout << '\n';
  }
}
void eleva(long long exponente) {
  for (int i = 0; i < M; ++i) {
    RET[i][i] = 1;
  }
  while (exponente > 0) {
    if (exponente & 1) {
      multiplica(A, RET);
      copia(temp, RET);
    }
    multiplica(A, A);
    copia(temp, A);
    exponente >>= 1;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long N;
  cin >> N >> M;
  if (N < M) {
    cout << 1 << '\n';
    return 0;
  }
  A[0][0] = 1;
  A[0][M - 1] = 1;
  for (int i = 0; i < M - 1; ++i) {
    A[i + 1][i] = 1;
  }
  eleva(N - M + 1);
  long long resp = 0;
  for (int i = 0; i < M; ++i) resp = (resp + RET[0][i]) % MOD;
  cout << resp << '\n';
  return 0;
}
