#include <bits/stdc++.h>
using namespace std;
long long n;
long long m;
array<array<long long, 105>, 105> a;
array<array<long long, 105>, 105> b;
void copy(array<array<long long, 105>, 105> &b,
          array<array<long long, 105>, 105> &a) {
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) b[i][j] = a[i][j];
}
void mul(array<array<long long, 105>, 105> &c,
         array<array<long long, 105>, 105> &a,
         array<array<long long, 105>, 105> &b) {
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) c[i][j] = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < m; k++)
        c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % 1000000007;
}
void calc(array<array<long long, 105>, 105> &b,
          array<array<long long, 105>, 105> &a, long long n) {
  if (n == 1) {
    copy(b, a);
    return;
  }
  calc(b, a, n / 2);
  array<array<long long, 105>, 105> c;
  mul(c, b, b);
  if (n % 2 == 1)
    mul(b, c, a);
  else
    copy(b, c);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  if (n < m) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) a[i][j] = 0;
  for (int i = 0; i < m - 1; i++) a[i][i + 1] = 1;
  a[m - 1][0] = 1;
  a[m - 1][m - 1] = 1;
  calc(b, a, n - m + 1);
  long long ans = 0;
  for (int j = 0; j < m; j++) ans = (ans + b[m - 1][j]) % 1000000007;
  cout << ans;
  return 0;
}
