#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long N;
int M;
struct Matrix {
  const static int maxn = 103;
  long long v[maxn][maxn];
  int n;
  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] + mod) % mod;
        }
      }
    }
    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;
  }
};
int main() {
  cin >> N >> M;
  if (N < M) {
    cout << 1 << endl;
    return 0;
  }
  long long start_vector[M];
  Matrix c(M);
  c.v[0][0] = 1;
  c.v[0][M - 1] = 1;
  for (int i = 1; i < M; i++) {
    c.v[i][i - 1] = 1;
  }
  Matrix res = c ^ (N - M + 1);
  long long sum = 0;
  for (int i = 0; i < M; i++) {
    sum = (sum + res.v[0][i] + mod) % mod;
  }
  cout << sum << endl;
}
