#include <bits/stdc++.h>
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
using namespace std;
const int INF = 0x3f3f3f3f;
const long long mod = 1000000007;
long long n, m;
vector<vector<long long>> A(101, vector<long long>(101, 0));
vector<vector<long long>> multipy(vector<vector<long long>> &A,
                                  vector<vector<long long>> &B) {
  vector<vector<long long>> ans(101, vector<long long>(101, 0));
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j) {
      long long x = 0;
      for (int k = 0; k < m; ++k) {
        x += A[i][k] * B[k][j];
        x %= mod;
      }
      ans[i][j] = x;
    }
  }
  return ans;
}
vector<vector<long long>> quickpow(long long N) {
  vector<vector<long long>> ans(101, vector<long long>(101, 0));
  for (int i = 0; i < 101; ++i) {
    ans[i][i] = 1;
  }
  while (N) {
    if (N & 1) {
      ans = multipy(ans, A);
    }
    A = multipy(A, A);
    N >>= 1;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  if (n <= m) {
    cout << 1 + (n == m ? 1 : 0) << endl;
    return 0;
  }
  A[0][0] = A[0][m - 1] = 1;
  for (int i = 1; i < m; ++i) {
    A[i][i - 1] = 1;
  }
  A = quickpow(n - m);
  long long ans = A[0][0] * 2 % mod;
  for (int i = 1; i < m; ++i) {
    ans += A[0][i];
    ans %= mod;
  }
  cout << ans << endl;
}
