#include <bits/stdc++.h>
using namespace std;
struct Matrix {
  const static int N = 105;
  int n;
  long long v[N][N];
  Matrix() { n = 0; }
  Matrix(int _n) : n(_n) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) v[i][j] = 0;
  }
  Matrix operator*(const Matrix &o) const {
    Matrix res(n);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        for (int k = 0; k < n; k++)
          res.v[i][j] =
              ((res.v[i][j] + v[i][k] * o.v[k][j]) % (long long)(1e9 + 7) +
               (long long)(1e9 + 7)) %
              (long long)(1e9 + 7);
    return res;
  }
  static Matrix getIdentity(int n) {
    Matrix res(n);
    for (int i = 0; i < n; i++) res.v[i][i] = 1;
    return res;
  }
  Matrix operator^(long long k) const {
    Matrix res = Matrix::getIdentity(n);
    Matrix a = *this;
    while (k) {
      if (k & 1) res = res * a;
      a = a * a;
      k /= 2;
    }
    return res;
  }
};
Matrix mat;
int main() {
  long long n, m;
  scanf("%lld %lld", &n, &m);
  mat = Matrix(m);
  mat.v[0][0] = 1;
  mat.v[0][m - 1] = 1;
  for (int i = 1; i < m; i++) {
    mat.v[i][i - 1] = 1;
  }
  if (n < m) {
    printf("1\n");
    return 0;
  }
  mat = mat ^ (n - m + 1);
  long long out = 0;
  for (int i = 0; i < m; i++) {
    out = ((out + mat.v[0][i]) % (long long)(1e9 + 7) + (long long)(1e9 + 7)) %
          (long long)(1e9 + 7);
  }
  printf("%lld\n", out);
  return 0;
}
