#include <bits/stdc++.h>
using namespace std;
struct Mat {
  long long n, m, a[((long long)90)][((long long)90)];
  Mat() {
    for (int i = 0; i < ((long long)90); i++)
      for (int j = 0; j < ((long long)90); j++) a[i][j] = 0;
  }
  Mat operator*(Mat B) {
    Mat ex;
    ex.n = n;
    ex.m = B.m;
    for (int k = 0; k < m; k++)
      for (int i = 0; i < ex.n; i++)
        for (int j = 0; j < ex.m; j++)
          ex.a[i][j] += (a[i][k] * B.a[k][j]),
              ex.a[i][j] %= ((long long)1e9 + 7);
    return ex;
  }
  Mat operator^(long long val) {
    Mat ex;
    ex.n = n;
    ex.m = m;
    for (int i = 0; i < n; i++) ex.a[i][i] = 1;
    Mat now = (*this);
    while (val) {
      if (val % 2) ex = ex * now;
      now = now * now;
      val /= 2;
    }
    return ex;
  }
};
long long n, k, tvn2[((long long)90)], c[((long long)90)][((long long)90)];
Mat res, ans;
int main() {
  cin >> n >> k;
  tvn2[0] = 1;
  for (int i = 1; i < ((long long)90); i++)
    tvn2[i] = (tvn2[i - 1] * 2) % ((long long)1e9 + 7);
  for (int i = 0; i < ((long long)90); i++) c[i][0] = c[i][i] = 1;
  for (int i = 1; i < ((long long)90); i++)
    for (int j = 1; j < i; j++)
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % ((long long)1e9 + 7);
  res.n = res.m = 83;
  for (int i = 41; i <= 81; i++) res.a[i][i - 41] = 1;
  for (int i = 0; i <= 40; i++) {
    for (int j = 0; j <= i; j++) res.a[i][j] = c[i][j];
    for (int j = 0; j <= i; j++)
      res.a[i][j + 41] = (tvn2[i - j] * c[i][j]) % ((long long)1e9 + 7);
  }
  res.a[82][82] = res.a[82][k] = 1;
  ans.n = 83;
  ans.m = 1;
  for (int i = 0; i <= 41; i++) ans.a[i][0] = 1;
  ans.a[82][0] = 1;
  res = res ^ n;
  ans = res * ans;
  cout << (ans.a[82][0] - 1 + ((long long)1e9 + 7)) % ((long long)1e9 + 7)
       << "\n";
  return 0;
}
