#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
void pre() {}
void solve() {}
vector<int> s[400009];
struct UF {
  vector<int> e;
  UF(int n) : e(n, -1) {}
  bool same_set(int a, int b) { return find(a) == find(b); }
  int size(int x) { return -e[find(x)]; }
  int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
  void join(int a, int b) {
    a = find(a), b = find(b);
    if (a == b) return;
    if (e[a] > e[b]) swap(a, b);
    e[a] += e[b];
    e[b] = a;
  }
};
long long temp[102][102];
long long temp1[102][102];
long long temp2[102][102];
long long p = 1000000007;
void multiple(int a) {
  if (a == 1) {
    for (int i = 0; i < 102; i++) {
      for (int j = 0; j < 102; j++) {
        long long x = 0, y, z, m, n, l;
        for (int k = 0; k < 102; k++) {
          x = (x + temp[i][k] * temp[k][j]) % p;
        }
        temp2[i][j] = x;
      }
    }
    for (int i = 0; i < 102; i++) {
      for (int j = 0; j < 102; j++) {
        temp[i][j] = temp2[i][j];
      }
    }
  } else {
    for (int i = 0; i < 102; i++) {
      for (int j = 0; j < 102; j++) {
        long long x = 0, y, z, m, n, l;
        for (int k = 0; k < 102; k++) {
          x = (x + temp[i][k] * temp1[k][j]) % p;
        }
        temp2[i][j] = x;
      }
    }
    for (int i = 0; i < 102; i++) {
      for (int j = 0; j < 102; j++) {
        temp[i][j] = temp2[i][j];
      }
    }
  }
}
long long ans_(long long n, long long m) {
  if (n == 1) {
    long long x = 0;
    for (int i = 0; i < m; i++) x = (x + temp[0][i]) % p;
    return x;
  }
  ans_(n / 2, m);
  multiple(1);
  if (n % 2 != 0) multiple(0);
  long long x = 0;
  for (int i = 0; i < m; i++) x = (x + temp[0][i]) % p;
  return x;
  return (temp[0][0] + temp[0][m - 1]) % p;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  long long n, m;
  cin >> n >> m;
  temp[0][0] = 1;
  temp1[0][0] = 1;
  temp[0][m - 1] = 1;
  temp1[0][m - 1] = 1;
  int j = 0;
  for (int i = 1; i < m; i++) {
    temp[i][j] = 1;
    temp1[i][j] = 1;
    j++;
  }
  if (n < m)
    cout << 1 << endl;
  else {
    cout << ans_(n - m + 1, m) << endl;
  }
  return 0;
}
