#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<long long> state[10010];
long long second, ans;
map<vector<long long>, long long> mm;
long long trans[10010][4];
long long dp[1010][10010];
long long get_id(vector<long long> v) {
  if (mm.count(v)) return mm[v];
  state[second] = v;
  mm[v] = second;
  return second++;
}
void func(long long id) {
  long long i, j;
  for (i = 0; i < 4; i++) {
    vector<long long> w = state[id];
    for (j = 0; j < 4; j++) {
      if (i == j)
        w[j] = ((w[j] == m) ? m : 0);
      else
        w[j] = min(w[j] + 1, m);
    }
    sort(w.begin(), w.end());
    trans[id][i] = get_id(w);
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  vector<long long> tp;
  for (long long i = 0; i < 4; i++) tp.push_back(0);
  get_id(tp);
  long long pos = 0;
  while (pos < second) {
    func(pos);
    pos++;
  }
  dp[0][0] = 1;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < second; j++)
      for (long long k = 0; k < 4; k++) {
        long long jj = trans[j][k];
        dp[i + 1][jj] = (dp[i + 1][jj] + dp[i][j]) % 1000000009;
      }
  for (long long i = 0; i < second; i++) {
    bool flg = 0;
    for (long long j = 0; j < 4; j++)
      if (state[i][j] != m) flg = 1;
    if (flg) {
      ans += dp[n][i];
      ans %= 1000000009;
    }
  }
  cout << ans << endl;
  return 0;
}
