#include <bits/stdc++.h>
bool isp(long long x) {
  if (x < 2) return 0;
  for (long long i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return 0;
  }
  return 1;
}
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
long long gcd(long long x, long long y) { return !y ? x : gcd(y, x % y); }
using namespace std;
long long n, P = 1e9 + 7, k;
struct Matrix {
  long long data[105][105];
  void clear() { memset(data, 0, sizeof(data)); }
  void identity() {
    clear();
    for (long long i = 1; i <= n; i++) data[i][i] = 1;
  }
} A, ans;
Matrix mul(Matrix a, Matrix b) {
  Matrix c;
  c.clear();
  for (long long k = 1; k <= n; k++) {
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= n; j++) {
        c.data[i][j] = (c.data[i][j] + a.data[i][k] * b.data[k][j] % P) % P;
      }
    }
  }
  return c;
}
void pow_mod(Matrix n, long long mt) {
  for (; mt; mt /= 2) {
    if (mt & 1) {
      ans = mul(ans, n);
    }
    n = mul(n, n);
  }
  return;
}
int main() {
  cin >> k >> n;
  if (k < n) {
    puts("1");
    return 0;
  }
  for (long long i = 1; i < n; i++) {
    ans.data[1][i] = 1;
    A.data[i + 1][i] = 1;
  }
  ans.data[1][n] = 2;
  A.data[1][n] = 1;
  A.data[n][n] = 1;
  pow_mod(A, k - n);
  cout << ans.data[1][n] % P;
  return 0;
}
