#include <bits/stdc++.h>
using namespace std;
const long long kMod = 1000000009;
int N, H;
long long f[2][2][35][35][35];
void read();
void soups_on();
int main() {
  read();
  soups_on();
  return 0;
}
void read() { cin >> N >> H; }
void soups_on() {
  int p, q, vs[4], vt[4];
  long long t;
  p = 1, q = 0;
  f[q][1][1][1][1] = 4;
  H = min(H, N);
  for (int i1 = 1; i1 < N; ++i1) {
    swap(p, q);
    fill(&f[q][0][0][0][0], &f[q + 1][0][0][0][0], 0);
    for (int i2 = 0; i2 < 2; ++i2)
      for (int j1 = 1; j1 <= H; ++j1)
        for (int j2 = 1; j2 <= H; ++j2)
          for (int j3 = 1; j3 <= H; ++j3) {
            if (!(t = f[p][i2][j1][j2][j3])) continue;
            t %= kMod;
            vs[0] = vt[0] = i2 ? 0 : H;
            vs[1] = vt[1] = j1, vs[2] = vt[2] = j2, vs[3] = vt[3] = j3;
            for_each(vt, vt + 4, [=](int &ri) { ri = min(ri + 1, H); });
            for (int k = 0; k < 4; ++k) {
              int nv, nj1, nj2, nj3;
              nv = vs[k] < H ? 1 : 0;
              nj1 = vt[(k + 1) % 4];
              nj2 = vt[(k + 2) % 4];
              nj3 = vt[(k + 3) % 4];
              f[q][nv][nj1][nj2][nj3] += t;
            }
          }
  }
  long long res = 0;
  for (int i = 0; i < 2; ++i)
    for (int j1 = 1; j1 <= H; ++j1)
      for (int j2 = 1; j2 <= H; ++j2)
        for (int j3 = 1; j3 <= H; ++j3)
          if (i || j1 < H || j2 < H || j3 < H)
            res += f[q][i][j1][j2][j3], res %= kMod;
  cout << res << "\n";
}
