#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define FORE(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fi   first
#define se   second
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
#define endl '\n'

const int N = 25, T = 15;
ll dp[N][5][5][5][T][T];

int main(int argc, char const *argv[])
{
	clock_t tStart = clock();

	int n, t;
	scanf("%d %d", &n, &t);

	//base case
	FOR(cur, 1, 4) FOR(prev1, 1, 4) FOR(prev2, 1, 4)
		if (prev1 > cur && prev1 > prev2) dp[3][cur][prev1][prev2][1][0] = 1;
		else if (prev1 < cur && prev1 < prev2) dp[3][cur][prev1][prev2][0][1] = 1;
		else if (prev1 != cur && prev1 != prev2) dp[3][cur][prev1][prev2][0][0] = 1;

	FOR(i, 4, n) FOR(cur, 1, 4) FOR(prev1, 1, 4) FOR(prev2, 1, 4) FOR(up, 0, t) FOR(down, 0, t) {
		if (prev1 == cur || prev1 == prev2) continue;
		bool print = (i == 4 && cur == 1 && prev1 == 2 && prev2 == 1 && up == 1 && down == 1);
		ll sum = 0;
		FOR(prev3, 1, 4) {
			sum += dp[i - 1][prev1][prev2][prev3][up - (prev1 > cur && prev1 > prev2)][down - (prev1 < cur && prev1 < prev2)];
		}
		dp[i][cur][prev1][prev2][up][down] = sum;
		//if (i == 4) fprintf(stdout, "dp[%d][%d][%d][%d][%d][%d] : %d\n", i, cur, prev1, prev2, up, down, dp[i][cur][prev1][prev2][up][down]);
	}

	ll res = 0;
	FOR(cur, 1, 4) FOR(prev1, 1, 4) FOR(prev2, 1, 4) res += dp[n][cur][prev1][prev2][t][t - 1];
	printf("%I64d\n", res);

	fprintf(stderr, "Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
	return 0;
}

//============================================================================
// File        : main.cpp
// Author      : AHMED HANI IBRAHIM
// Copyright   : AHani
// Version     :
// Created on February 5, 2013, 7:44 AM
//============================================================================

#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#define Max 50 + 5
#define INF 1000000000
//#define INT_MAX 2147483647
#define FOR(i, N) for( int i = 0 ; i < N ; i++ )
#define FOR1e(i, N) for( int i = 1 ; i <= N ; i++ )
#define FORe(i, N) for(int i = 0 ; i <= N ; i++ )
#define FOR1(i, N) for(int i = 1 ; i < N ; i++ )
#define BLUE 1
#define RED 2
#define LL long long
using namespace std;

int N, T;
LL Memo[Max][10][10][12][12];

LL solve(int pos, int last1, int last2, int count1, int count2) {
    if (pos == N) {
        if (count1 == T && count2 == T-1)
            return 1;
        return 0;
    }
    if (count1 > T)
        return 0;
    if (count2 > T - 1)
        return 0;
    LL &ret = Memo[pos][last1][last2][count1][count2];
    if (ret < 0) {
        ret = 0;
        FOR(next, 4) if (next != last2) {
            if (last1 == 4 || last2 == 4) {
                ret += solve(pos + 1, last2, next, count1, count2);
            } else {
                int ncount1 = count1;
                int ncount2 = count2;
                if (last1 < last2 && last2 > next)
                    ++ncount1;
                if (last1 > last2 && last2 < next)
                    ++ncount2;
                ret += solve(pos+1, last2, next, ncount1, ncount2);
            }
        }
    }
    return ret;
}

int main(int argc, char** argv) {
   //    freopen("Trojan.txt", "r", stdin);
    scanf("%d %d", &N, &T);
    memset(Memo, -1, sizeof(Memo));
    cout << solve(0, 4, 4, 0, 0) << endl;

    return 0;
}

//This program is written by Brian Peng.
#include<bits/stdc++.h>
using namespace std;
#define Rd(a) (a=rd())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int rd(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=x*10+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (30)
int n,t,f[N][N][N][10][2],ans;
int dfs(int n,int u,int v,int d,bool c);
signed main(){
	Rd(n),Rd(t),Mst(f,-1);
	Frn1(i,1,4)ans+=dfs(n,t,t-1,i,0)+dfs(n,t,t-1,i,1);
	wr(ans),exit(0);
}
int dfs(int n,int u,int v,int d,bool c){
	if(u+v>n-2||u<0||v<0)return 0;
	if(~f[n][u][v][d][c])return f[n][u][v][d][c];f[n][u][v][d][c]=0;
	if(n==2)return f[n][0][0][d][c]=c?d-1:4-d;
	else if(c)Frn0(i,1,d)Frn1(j,0,1)f[n][u][v][d][c]+=dfs(n-1,u,v-(!j),i,j);
	else Frn1(i,d+1,4)Frn1(j,0,1)f[n][u][v][d][c]+=dfs(n-1,u-j,v,i,j);
	return f[n][u][v][d][c];
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <memory.h>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
const double eps = 1e-12;
const int INF = 1<<30;
const LL LINF = 1ll<<60;

#define pb push_back
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define CLR(a, v) memset((a),(v),sizeof(a))
#define sqr(a) ((a)*(a))
const int BUFFER_SZ = 1<<10;
const int MOD = 1000*1000*1000+7;

char BUFFER[BUFFER_SZ];
int gi() { int x; scanf("%d", &x); return x; }
double gd() { double x; scanf("%lf", &x); return x; }
LL gll() { LL x; scanf("%lld", &x); return x; }
VI gvi(int n) { VI a; while(n-->0) a.pb(gi()); return a;}
string gs() { scanf("%s", BUFFER); return string(BUFFER); }
template <class T> void print(vector<T> &x, string format) { format += "%c";for (int i = 0; i < x.size(); ++i) printf(format.c_str(), x[i], i+1==x.size() ? '\n' : ' '); }
// ---------------------------------------------------------- //

LL dp[22][11][11][6];

LL rec(int p, int up, int down, int last) {
  LL &r = dp[p][up][down][last];
  if (r==-1) {
    r = 0;
    if (p==0) {
      r = (up==0&&down==1)?1:0;
    } else {
      for (int k = 1; k <= 4; ++k) {
        if (last == k) continue;
        if (up == down) {
          // going up:
          if (k < last && up > 0) {
            r += rec(p-1, up-1, down, k);
          } else if (k>last) {
            r += rec(p-1,up,down,k);
          }
        } else {
          // going down:
          if (k < last) {
            r += rec(p-1, up, down, k);
          } else if (k>last && down>0) {
            r += rec(p-1,up,down-1,k);
          }
        }
      }
    }
  }
  return r;
}

void solve() {
  int n = gi();
  int t = gi();
  CLR(dp,-1);
  LL res = 0;
  for (int a = 1; a <=4; ++a) for (int b=a+1; b<=4;++b) {
      //printf("%d%d: %d\n", a,b, rec(n-2,t,t,b));
      res += rec(n-2,t,t,b);
  }
  printf("%lld\n", res);
}

int main() {
#ifdef DEAD_RABBIT
  freopen("../in.txt","r",stdin);
  clock_t start = clock();
#endif
  solve();
#ifdef DEAD_RABBIT
  fprintf(stdout, "Time: %.3lf\n", 1.0*(clock()-start)/CLOCKS_PER_SEC);
#endif
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int MOD = 0;

const int S = 1 << 21;
char p0[S],*p1,*p2;
#ifndef ZXY
#define getchar() (p2 == p1 && (p2 = (p1 = p0) + fread(p0,1,S,stdin)) == p1 ? EOF : *p1++)
#endif
inline int read() {
	static int x,c;x = 0;
	do{c = getchar();}while(!isdigit(c));
	do{x = (x << 3) + (x << 1) + (c & 15);c = getchar();}while(isdigit(c));
	return x;
}

#define LL long long
#define fr(i,l,r) for(int i = (l);i <= (r);++i)
#define rf(i,l,r) for(int i = (l);i >= (r);--i)
#define foredge(i,u,v) for(int i = fir[u],v;v = to[i],i;i = nxt[i])
#define ci const int &

const int N = 23,K = 13;
int n,t;
LL dp[N][K][K][5][2],ans;
int main() {
	scanf("%d%d",&n,&t);
	for(int i = 1;i <= 4;++i) {
		dp[2][0][0][i][0] = 4-i;
		dp[2][0][0][i][1] = i-1;
	}
	for(int i = 3;i <= n;++i)
		fr(j,0,t) fr(k,0,t) fr(p,1,4) {
			for(int q = p+1;q <= 4;++q) {
				dp[i][j][k][p][0] += dp[i-1][j][k][q][0];
				dp[i][j][k][p][0] += dp[i-1][j-1][k][q][1];
			}
			for(int q = p-1;q >= 0;--q) {
				dp[i][j][k][p][1] += dp[i-1][j][k][q][1];
				dp[i][j][k][p][1] += dp[i-1][j][k-1][q][0];
			}
		}
	for(int i = 1;i <= 4;++i)
		ans += dp[n][t][t-1][i][0] + dp[n][t][t-1][i][1];
	printf("%lld\n",ans);
	return 0;
}

#include "bits/stdc++.h"
using namespace std;

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; i <= R; i++)
#define int long long

const int N = 2e5 + 2, inf = 1e18;

int n, t;
int dp[21][5][5][11][11];

int go(int id, int prev2, int prev1, int hills, int valleys) {
    if (id > n)
        return hills == t && valleys == t - 1;

    int &ans = dp[id][prev2][prev1][hills][valleys];
    if (~ans)
        return ans;
    ans = 0;

    FOR(next,1,4) if (next != prev1) {
        int is_hill = prev2 < prev1 && prev1 > next;
        int is_valley = prev2 > prev1 && prev1 < next;
        ans += go(id + 1, prev1, next, hills + is_hill, valleys + is_valley);

    }
    return ans;
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> t;

    memset(dp, -1, sizeof(dp));
    int ans = 0;
    FOR(fi,1,4) FOR(se,1,4) if (fi != se) {
        ans += go(3,fi,se,0,0);
    }

    cout << ans;
}

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,t,ans;
int f[21][5][5][12][12];
signed main(){
	//f[i][j][k][t1][t2]:前i位，第i位为j，第i-1位为k，前i-1位，t1个条件1，t2个条件2已经满足
	scanf("%lld%lld",&n,&t);
	for (register int i=1; i<=4; ++i)
	for (register int j=1; j<=4; ++j) if (i!=j) f[2][i][j][0][0]=1;
	for (register int l=3; l<=n; ++l)
	for (register int t1=0; t1<=t; ++t1)
	for (register int t2=0; t2<t; ++t2)
	for (register int i=1; i<=4; ++i)
	for (register int j=1; j<=4; ++j)
	for (register int k=1; k<=4; ++k)
	{
		if (k<j && j>i && t1+1<=t) f[l][i][j][t1+1][t2]+=f[l-1][j][k][t1][t2];
		else if (k>j && j<i && t2+1<=t) f[l][i][j][t1][t2+1]+=f[l-1][j][k][t1][t2];
		else if (k!=j && j!=i && k!=i) f[l][i][j][t1][t2]+=f[l-1][j][k][t1][t2];
	}
	for (register int i=1; i<=4; ++i)
	for (register int j=1; j<=4; ++j) if (i!=j) ans+=f[n][i][j][t][t-1];
	printf("%lld\n",ans);
return 0;
}

#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int32_t n, t;
  std::cin >> n >> t;
  std::vector dp(4, std::vector(4, std::vector(t + 1, std::vector<int64_t>(t))));
  for(size_t i = 0; i < 4; ++i){
    for(size_t j = 0; j < 4; ++j){
      if(i == j){
        continue;
      }
      dp[i][j][0][0] = 1;
    }
  }
  for(size_t i = 2; i < n; ++i){
    std::vector next(4, std::vector(4, std::vector(t + 1, std::vector<int64_t>(t))));
    for(size_t v = 0; v < 4; ++v){
      for(size_t a = 0; a < 4; ++a){
        for(size_t b = 0; b < 4; ++b){
          if(b == v){
            continue;
          }
          for(size_t x = 0; x <= t; ++x){
            for(size_t y = 0; y < t; ++y){
              if(a < b && b > v){
                if(x > 0){
                  next[b][v][x][y] += dp[a][b][x - 1][y];
                }
              }else if(a > b && b < v){
                if(y > 0){
                  next[b][v][x][y] += dp[a][b][x][y - 1];
                }
              }else{
                next[b][v][x][y] += dp[a][b][x][y];
              }
            }
          }
        }
      }
    }
    dp = next;
  }
  int64_t result = 0;
  for(size_t i = 0; i < 4; ++i){
    for(size_t j = 0; j < 4; ++j){
      result += dp[i][j][t][t - 1];
    }
  }
  std::cout << result << std::endl;
}

#include <cstdio>
#include <cstring>

using namespace std;

int t,n,k;
int dp[23][23][23][13][13];

int main(){
    //scanf("%d",&t);
   // while(t--){
        scanf("%d %d",&n,&k);
        memset(dp,0,sizeof dp);
        for (int i=1; i<=4; i++)
            for (int j=1; j<=4; j++)
                if (i!=j)
                    dp[2][i][j][0][0]=1;
        for (int x=3; x<=n; x++)
            for (int i=1; i<=4; i++)
                for (int j=1; j<=4; j++)
                    if (i!=j)
                        for (int l=1; l<=4; l++)
                            if (l!=j)
                                for (int a=0; a<=k; a++)
                                    for (int b=0; b<k; b++){
                                        int up=0,down=0;
                                        if (l>j and j<i){
                                            if (b==k-1)
                                                continue;
                                            down=1;
                                        }
                                        else if (l<j and j>i){
                                            up=1;
                                            if (a==k)
                                                continue;
                                        }
                                        dp[x][l][j][a+up][b+down]+=dp[x-1][j][i][a][b];
                                    }
        int sol=0;
        for (int i=1; i<=4; i++)
            for (int j=1; j<=4; j++)
                if (i!=j)
                    sol+=dp[n][i][j][k][k-1];
        printf("%d\n",sol);
   // }
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
//#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;

const int N = 21;
const int M = 20;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, T;

int dp[N][N][N] = {0};

int DP(int s, int h, int t)
{
	if (s == n && t == 2*T - 1)
		return 1;
	if (s == n && t < 2*T - 1 || t > 2*T - 1)
		return 0;
	if (dp[s][h][t] != -1)
		return dp[s][h][t];
	int cnt = 0;
	for (int i = h - 1; i>=1; i--)
		cnt += DP(s + 1, i, t + (t+1)%2);
	for (int i = h + 1; i<=4; i++)
		cnt+=DP(s+1, i, t + t%2);
	dp[s][h][t] = cnt;
	return cnt;
}

INT main()
{
//	freopen("magic.in", "r", stdin);
//	freopen("magic.out", "w", stdout);
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> n >> T;
	forn(i, N)
		forn(j, N)
			forn(k, N)
				dp[i][j][k] = -1;
	int cnt = 0;
	for (int i = 1; i<=4; i++)
		for (int j = i+1; j<=4; j++)
			cnt += DP(2, j, 0);
	cout << cnt << endl;
//	cin >> n;
	return 0;
}

#ifdef PRAGMA_COMMENT_LINKER
#pragma comment(linker, "/STACK:16777216")
#endif

#define  _CRT_SECURE_NO_WARNINGS
#define  NDEBUG

#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define all(v)                  (v).begin(), (v).end()
#define db(x)                   cerr << #x << '=' << (x) << "\n"
#define fend(x)                 ((x) & ((x)+1)) - 1
#define fenu(x)                 (x) | ((x)+1)
#define ft                      first
#define len(s)                  s.length()
#define maxV(type)              std::numeric_limits<type>::max()
#define minV(type)              std::numeric_limits<type>::min()
#define mp(a, b)                std::make_pair((a), (b))
#define ord(c)                  ((c) - 'a' + 1)
#define pob()                   pop_back()
#define pof()                   pop_front()
#define pub(s)                  push_back((s))
#define puf(s)                  push_front((s))
#define sc                      second

typedef double                  f32;
typedef long double             f64;
typedef long long               i64;
typedef unsigned long long      u64;

const   long double             EPS = 0.0000001;
const   long double             PI = 3.14159265358979323846;

inline int lg2(i64 n) { int h = 0; while ((1 << h) < n) ++h; return h; }

struct configio {
	configio() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
} cnfio;

int main() {
	//freopen("strings.in", "r", stdin);
	//freopen("strings.out", "w", stdout);
	static i64 dp[25][5][5][15][15];
	for (int i = 0; i < 5; ++i)
		for (int j = 0; j < 5; ++j)
			dp[2][i][j][0][0] = 1;
	for (int i = 3; i < 21; ++i) {
		for (int hp = 1; hp < 5; ++hp) {
			for (int h = 1; h < 5; ++h) {
				for (int a = 0; a < 11; ++a) {
					for (int b = 0; b < 11; ++b) {
						dp[i][hp][h][a][b] = 0;
						for (int hpp = 1; hpp < 5; ++hpp) {
							dp[i][hp][h][a][b] += dp[i - 1][hpp][hp][a - 1][b] * (hp < hpp && hp < h);
						}
						for (int hpp = 1; hpp < 5; ++hpp) {
							dp[i][hp][h][a][b] += dp[i - 1][hpp][hp][a][b] * (hp > hpp || hp > h);
						}
						for (int hpp = 1; hpp < 5; ++hpp) {
							dp[i][hp][h][a][b] += dp[i - 1][hpp][hp][a][b - 1] * (hp > hpp && hp > h);
						}
					}
				}
			}
		}
	}
	int n, t;
	cin >> n >> t;
	i64 ans = 0;
	for (int i = 1; i < 5; ++i)
		for (int j = 1; j < 5; ++j)
			ans += dp[n][i][j][t - 1][t];
	cout << ans << endl;
	return 0;
}

// Believe in yourself...
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) (c).size()
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)

#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll maxn=21;

ll dp[maxn][maxn][5][2];// n // t // now // decreasing?0 increasing?1

int main(){
	ll n,t;cin>>n>>t;
	dp[2][0][2][1]=1;
	dp[2][0][3][1]=2;
	dp[2][0][4][1]=3;

	dp[2][0][2][1]=1;
	dp[2][0][3][1]=2;
	dp[2][0][4][1]=3;
	dp[3][0][3][1]=1;
	dp[3][0][4][1]=3;
	dp[4][0][4][1]=1;
	FOR(i,3,n){
		FOR(j,1,t){
			FOR(now,1,4){
				FOR(bef,1,(now-1))
					dp[i][j][now][1]+=dp[i-1][j][bef][1]+dp[i-1][j][bef][0];
				FOR(bef,now+1,4)
					dp[i][j][now][0]+=dp[i-1][j-1][bef][1]+dp[i-1][j][bef][0];
			}
		}
	}
	ll sm=0;
	FOR(i,1,4)
		sm+=dp[n][t][i][0];
	cout<<sm;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#include <queue>

using namespace std;

typedef long long ll;

const int N = 1010;

int n , t ;

ll dp[21][11][11][6][6];

int calc(int idx , int up , int down,int p , int pp){
	if(up < 0)
		return 0;
	if(down < 0)
		return 0;
	if(idx == n){
		return (up == 0 && down == 0);
	}
	ll &ret = dp[idx][up][down][p][pp];
	if(ret != -1)
		return ret;
	ret = 0;
	if(idx < 2){
		for(int nxt = 1 ; nxt <= 4 ; nxt++){
			if(idx == 1 && nxt != p){
				ret += calc(idx + 1, up , down , p , nxt);
			}else{
				ret += calc(idx + 1, up , down , nxt , 0 );
			}
		}
	}else{
		for(int nxt = 1 ; nxt <= 4; nxt++){
			if(p < pp && pp > nxt){
				ret += calc(idx + 1 , up - 1 , down , pp , nxt);
			}else if(p > pp && pp < nxt){
				ret += calc(idx + 1, up , down - 1 , pp , nxt);
			}else if(nxt != pp){
				ret += calc(idx + 1, up , down , pp,nxt);
			}
		}
	}
	return ret;
}
int main(){
	//freopen("input.txt","r",stdin);
	memset(dp,-1,sizeof dp);
	cin >> n >> t;
	cout << calc(0,t,t-1,0,0) << endl;
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <memory.h>
#include <hash_map>
#include <string>
#include <tuple>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <set>
#define cs(x) (int)x.size()
#define mp(x, y) make_pair(x, y)
#define EPS 1e-12
#define mod 1000000007ll
#define ld long double
#define pb push_back
#define sqr(x) (x)*(x)
#define ll long long
#define INF 1000000000LL
#define task "robot"
#define pii pair<int, int>
#define left _left
#define right _right
using namespace std;

int n, t;

ll dp[21][11][11][5][5] = { 0 };

ll calc(int curn, int lastgorb, int lastnegorb, int cury, int last)
{
	if (dp[curn][lastgorb][lastnegorb][cury][last] != -1)
		return dp[curn][lastgorb][lastnegorb][cury][last];
	if (lastgorb > t)
		return dp[curn][lastgorb][lastnegorb][cury][last] = 0;
	if (lastnegorb >= t)
		return dp[curn][lastgorb][lastnegorb][cury][last] = 0;
	if (lastgorb < 0 || lastnegorb < 0)
		return dp[curn][lastgorb][lastnegorb][cury][last] = 0;
	if (cury == last)
		return dp[curn][lastgorb][lastnegorb][cury][last] = 0;
	if (curn == 1)
	{
		if (lastgorb == t && lastnegorb == (t - 1))
			return dp[curn][lastgorb][lastnegorb][cury][last] = 1;
		else
			return dp[curn][lastgorb][lastnegorb][cury][last] = 0;
	}
	ll ans = 0;
	for (int lastlast = 1; lastlast <= 4; lastlast++)
	{
		if (lastlast == last)
			continue;
		if (lastlast < last && last > cury)
		{
			//GOOOORB
			ans += calc(curn - 1, lastgorb + 1, lastnegorb, last, lastlast);
		}
		else if (lastlast > last && last < cury)
		{
			//NEEEEE GOOOOOORB
			ans += calc(curn - 1, lastgorb, lastnegorb + 1, last, lastlast);
		}
		else
		{
			ans += calc(curn - 1, lastgorb, lastnegorb, last, lastlast);
		}
	}
	return dp[curn][lastgorb][lastnegorb][cury][last] = ans;
}

int main()
{
	//freopen(task ".in", "r", stdin);
	cin >> n >> t;
	ll ans = 0;
	for (int i = 0; i < 21; i++)
	{
		for (int j = 0; j < 11; j++)
		{
			for (int z = 0; z < 11; z++)
			{
				for (int q = 0; q < 5; q++)
				{
					for (int t = 0; t < 5; t++)
					{
						dp[i][j][z][q][t] = -1;
					}
				}
			}
		}
	}
	for (int i = 1; i <= 4; i++)
	{
		for (int last = 1; last <= 4; last++)
		{
			if (last == i)
				continue;
			ans += calc(n - 1, 0, 0, i, last);
		}
	}
	cout << ans << endl;
	return 0;
}

/*
 * PROB: Codeforces - 14E - Camels
 * LANG: C++
 */

#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

#define rp(i,a,b) \
    for (int i = int(a), n##i = int(b); i <= n##i; i++)

int n, t, f[70][6][20];

void pre_calc() {
    memset(f, 0, sizeof f);
    f[1][1][0] = f[1][2][0] = f[1][3][0] = 1;
    rp(i,2,4)rp(k,i,4)rp(h,i-1,k-1)
        f[i][k][0] += f[i-1][h][0];
}

int solve() {
    pre_calc();
    rp(b,1,2*t-1)
        rp(i,b+2,3*b+4)
            rp(h,1,4) {
                if (b&1) {
                    if (h<4) f[i][h][b] = f[i-1][4][b-1];
                    rp(H,h+1,3)
                        f[i][h][b] += f[i-1][H][b-1] + f[i-1][H][b];
                } else {
                    if (h>1) f[i][h][b] = f[i-1][1][b-1];
                    rp(H,2,h-1)
                        f[i][h][b] += f[i-1][H][b-1] + f[i-1][H][b];
                }
            }
    int ans = 0;
    rp(i,1,4)
        ans += f[n][i][2*t-1];
    return ans;
}

int main(void) {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "wt", stdout);
#endif
    cin >> n >> t;
    int ans = 0;
    ans += solve();
    cout << ans;
    return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

const int N = 210;
int dp[25][5][15][2]; //第i位，值为j，处理到k峰，向上(0)还是向下(1)

int main()
{
    int n,t;
    scanf("%d%d",&n,&t);
    for(int j = 1; j <= 4; j++)
        dp[1][j][0][1] = 1;
    for(int i = 2; i <= n; i++){
        for(int k = 1; k <= t; k++){
            for(int j = 1; j <= 4; j++){
                for(int pre = 1; pre <= 4; pre++)
                {
                    if(pre > j)
                    {
                        dp[i][j][k][1] += dp[i-1][pre][k][0];
                        dp[i][j][k][1] += dp[i-1][pre][k][1];
                    }
                    else if(pre < j)
                    {
                        dp[i][j][k][0] += dp[i-1][pre][k-1][1];
                        dp[i][j][k][0] += dp[i-1][pre][k][0];
                    }
                }
                //printf("i=%d j=%d k=%d dp0=%d dp1=%d\n",i,j,k,dp[i][j][k][0],dp[i][j][k][1]);
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= 4; i++)
        ans += dp[n][i][t][1];
    printf("%d\n",ans);
    return 0;
}

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define fore(i,n) for(int i = 0; i< n ; i++ )
#define lop(i,n) for(int i = 1 ; i<=n ; i++ )
#define ops(i,n) for(int  i = n-1 ; i>=0 ; i-- )
#define forall( it,g )  for( typeof(g.begin()) it=g.begin();it!=g.end();it++ )
#define PI  3.141592653589793
#define mod  1000000007
#define inf 2000000000
#define INF -2000000000
#define modulo 1000000009
#define MH 1234533333333337
#define MH2 7779845079489377
#define enter endl
//ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
using namespace std;
typedef vector <int> vi;
typedef vector <vector <int> > vv;
typedef vector <pair <int,int > >vp;
typedef vector <vector <pair <int ,int > > > vvp;
typedef vector <pair <int ,pair <int ,int > > > vpp;
typedef pair<int,int> pp;
typedef long long ll;
typedef unsigned long long ull;
int dp[22][11][11][5][5];
int m;
int ways(int n,int tt,int ttt,int last,int cur){
  if(n == m && tt == 0 && ttt == 0){
    return 1;
  }
  if(n >= m || tt < 0 || ttt<0){
    return 0;
  }
  int &temp = dp[n][tt][ttt][last][cur];
  if(temp!=-1)
    return temp;
  int ans = 0;
  lop(i , 4){
    if(n>=2){
      if(cur > i && cur > last){
        ans += ways(n+1,tt-1,ttt,cur,i);
      }else if(cur<i && cur<last)
        ans += ways(n+1,tt,ttt-1,cur,i);
      else if(i!=cur)ans+= ways(n+1,tt,ttt,cur,i);
    }else if(i!=cur){
      ans += ways(n+1,tt,ttt,cur,i);
    }
  }
  return temp = ans;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
  int t;
  cin >> m >> t;
  memset(dp,-1,sizeof dp);
  cout << ways(0,t,t-1,0,0) <<enter;
  return 0;
}

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <utility>

using namespace std;

typedef long long ll;
typedef long double ld;

const int MaxN = 22;

const int up = 0;
const int down = 1;

ll dp[MaxN][MaxN][MaxN][5][2];

int main() {
//	freopen("input.txt", "r", stdin);
	int n, t;
	cin >> n >> t;
	for (int i = 1; i <= 4; ++i) {
		for (int j = 1; j <= 4; ++j) {
			if (i == j)
				continue;
			if (i < j)
				dp[2][0][0][j][1] += 1;
			else
				dp[2][0][0][j][0] += 1;
		}
	}
	for (int i = 3; i <= n; ++i) {
		for (int t1 = 0; t1 <= t; ++t1) {
			for (int t2 = 0; t2 <= t; ++t2) {
				for (int last = 1; last <= 4; ++last) {
					for (int l1 = 0; l1 < last; ++l1) {
						dp[i][t1][t2][l1][0] += dp[i - 1][t1][t2][last][0];
						dp[i][t1 + 1][t2][l1][0] += dp[i - 1][t1][t2][last][1];
					}
					for (int l1 = last + 1; l1 <= 4; ++l1) {
						dp[i][t1][t2][l1][1] += dp[i - 1][t1][t2][last][1];
						dp[i][t1][t2 + 1][l1][1] += dp[i - 1][t1][t2][last][0];
					}
				}
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i <= 4;++i)
		ans += dp[n][t][t - 1][i][0] + dp[n][t][t - 1][i][1];
	cout << ans << endl;
	return 0;
}

#include <cassert>
#include <complex>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <sstream>
#include <utility>

#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <memory.h>
//#include "bigint.h"

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define init(st) memset(st, 0, sizeof(st))
#define ll long long

// String operations
template<class T>
void splitstr(const string &s, vector<T> &out) {
    istringstream in(s);
    out.clear();
    copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}

template<class T>
T readValue(string s) {
	T result;
	istringstream sin(s);
	sin >> result;
	return result;
}

template<class T>
void initArray(T *arr, int size, T value) {
    for (int i = 0; i < size; i++)
		arr[i] = value;
}

// Arithmetic operations
template<class T>
inline T gcd(T a, T b) {
	return (!a) ? b : gcd(b % a, a);
}

template<class T>
inline T mod(T a, T p) {
	a %= p;
	return (a < 0) ? a + p : a;
}

template<class T>
inline int num_bits(T n) {
	return (!n) ? 0 : 1 + numbits(n & (n - 1));
}

template<class T>
inline T inverse(T a, T m) {
	a = mod<T>(a,m);
	return (a==1) ? 1 : mod((1-m*inverse(m%a,a))/a,m);
}

template<class T>
inline bool is_prime(T a) {
	T lim = (T)sqrt((double)a);
	for (T i = 2; i <= T(lim+1E-9); i++)
		if (a % i == 0)
			return false;
	return true;
}

template<class T>
inline T power(T a, T p, T mod) {
	if (!p) return 1;
	T temp = power(a, p>>1, mod);
	temp = (temp * temp) % mod;
	if (p&1)
		temp = (temp * a) % mod;
	return temp;
}

void get_primes(int start, int end, vector<int> &vi) {
	int *p = new int[end + 1];
	initArray<int>(p, end+1, 0); p[1] = 1;
	for (int i = 2; i <= end; i++) {
		if (!p[i]) {
			if (i >= start)
				vi.push_back(i);
			for (int j = 2*i; j <= end; j += i)
				p[j] = 1;
		}
	}
    delete [] p;
}

// Graph operations
bool dfs(int current, int final, int total, int* visited, int **edges, bool flow) {
	if (current == final)
		return true;
	if (visited[current])
		return false;
	visited[current] = true;
	for (int i = 0; i < total; i++)
		if (edges[current][i] && dfs(i, final, total, visited, edges, flow)) {
			if (flow) {
				edges[current][i]--;
				edges[i][current]++;
			}
			return true;
		}
	return false;
}

int flow(int in, int out, int total, int **edges) {
	int result = 0;
	int *visited = new int[total];
	while (initArray<int>(visited, total, 0), dfs(in, out, total, visited, edges, true))
		result++;
    delete [] visited;
	return result;
}

// Disjoint datasets
void create_set(int x, int *P, int *rank) {
	P[x] = x;
	rank[x] = 0;
}

int find_set(int x, int *P) {
	if (x != P[x])
		P[x] = find_set(P[x], P);
	return P[x];
}

bool merge_sets(int x, int y, int *P, int *rank) {
	int Px = find_set(x, P);
	int Py = find_set(y, P);
	if(Px == Py)
		return false;
	if (rank[Px] > rank[Py]) P[Py] = Px;
	else P[Px] = Py;
	if (rank[Px] == rank[Py])
		rank[Py]++;
	return true;
}

// Binary tree operations
template <typename T>
int read_cum_freq(int index, T *tree) {
	int sum = 0;
	while (index) {
		sum += tree[index];
		index -= (index & -index);
	}
	return sum;
}

template <typename T>
void upd_freq(int index, int mxIndex, int value, T *tree) {
	while (index <= mxIndex) {
		tree[index] += value;
		index += (index & -index);
	}
}

template <typename T>
int read_freq(int index, T *tree) {
	return read_cum_freq(index, tree) - read_cum_freq(index-1, tree);
}

// String algos.
void build_failure_function(const string &str, int *temp_arr) {
    temp_arr[0] = temp_arr[1] = 0;
    for (int i = 2; i <= sz(str); i++) {
        temp_arr[i] = -1;
        for (int ind = temp_arr[i-1]; temp_arr[i] == -1; ind = temp_arr[ind]) {
            if (str[ind] == str[i-1]) {
                temp_arr[i] = ind + 1;
            } else if (ind == 0) {
                temp_arr[i] = 0;
            }
        }
    }
}

void KMP(const string &text, const string &pattern, int *res) {
    int *temp_arr = new int[sz(pattern) + 1];
    build_failure_function(pattern, temp_arr);
    int i = 0;
    int ind = 0;
    while (i < sz(text)) {
        if (text[i] == pattern[ind]) {
            res[i] = ++ind;
            if (res[i] == sz(pattern)) {
                ind = temp_arr[ind];
            }
            i++;
        } else if (ind == 0) {
            res[i++] = 0;
        } else {
            ind = temp_arr[ind];
        }
    }
    delete [] temp_arr;
}

// Setup
void setup(int value, string name) {
    string name_in = name + ".in";
    string name_out = name + ".out";
    freopen(name_in.c_str(), "r", stdin);
    if (value) {
        freopen(name_out.c_str(), "w", stdout);
    }
}

map<pair<int, int>, int> st1;
vector<pair<int, int> > vp;
set< pair< pair<int, int>, pair<int, int> > > st2;

map<int, vector<int> > roads;
bool visited[200];

int find(int prev, int cur, int to) {
    if (cur == to)
        return visited[cur] = true;
    for (int i = 0; i < roads[cur].size(); i++)
        if (roads[cur][i] != prev && find(cur, roads[cur][i], to))
            return visited[cur] = true;
    return false;
}

int find_sons(int cur, int &d) {
    if (visited[cur])
        return -1;
    visited[cur] = true;
    pair<int, int> tmp(0, 0);
    for (int i = 0; i < roads[cur].size(); i++) {
        int val = 1 + find_sons(roads[cur][i], d);
        if (val > tmp.second)
            tmp.second = val;
        if (tmp.first < tmp.second)
            swap(tmp.first, tmp.second);
    }
    d = max(d, tmp.first + tmp.second);
    return tmp.first;
}

int dp[32][4][4][32][32];

int main() {
#ifdef LOCAL_HOST
    setup(0, "input");
#endif
    int n, t;
    std::cin >> n >> t;
    init(dp);
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++)
            if (i != j)
                dp[1][i][j][0][0] = 1;
    for (int i = 1; i < n - 1; i++)
        for (int j = 0; j < 4; j++)
            for (int k = 0; k < 4; k++)
                for (int t1 = 0; t1 < 20; t1++)
                    for (int t2 = 0; t2 < 20; t2++) {
                        int cur = dp[i][j][k][t1][t2];
                        for (int m = 0; m < 4; m++) {
                            if (j > k && k < m)
                                dp[i+1][k][m][t1][t2+1] += cur;
                            else if (j < k && k > m)
                                dp[i+1][k][m][t1+1][t2] += cur;
                            else if (k != m)
                                dp[i+1][k][m][t1][t2] += cur;
                        }
                    }
    int res = 0;
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++)
            res += dp[n-1][i][j][t][t-1];
    std::cout << res << std::endl;
    return 0;
}

// 14E.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include <cmath>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

int dp[21][20][5][6];

int main()
{
	int n,t;
	scanf("%d%d",&n,&t);
	if(t>n)
	{
		printf("0");
		return 0;
	}

	dp[1][0][1][1]=1;
	dp[1][0][2][1]=1;
	dp[1][0][3][1]=1;

	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=2*t-1;j++)
		{
			for(int h=1;h<5;h++)
			{
				for(int p=1;p<5;p++)
				{
					if(j%2==0)
					{
						if(i!=n)
						{
							for(int k=h+1;k<5;k++)
							{
								dp[i][j][k][h]+=dp[i-1][j][h][p];
							}
						}

						if(i!=2)
						{
							if(p!=h)
							{
								for(int k=h-1;k>0;k--)
								{
									if(j+1<=2*t-1)
									{
										dp[i][j+1][k][h]+=dp[i-1][j][h][p];
									}
								}
							}
						}
					}//if(j%2=0)
					else
					{

						for(int k=h-1;k>0;k--)
						{
							dp[i][j][k][p]+=dp[i-1][j][h][p];
						}

						if(i!=n)
						{
							if(p!=h)
							{
								for(int k=h+1;k<5;k++)
								{
									if(j+1<=2*t-1)
									{
										dp[i][j+1][k][h]+=dp[i-1][j][h][p];
									}
								}
							}
						}
					}//else for if(j%2=0)
				}//for(int p=1;p<5;p++)
			}//for(int h=1;h<5;h++)
		}//for(int j=0;j<=2*t-1;j++)
	}//for(int i=2;i<=n;i++)

	long long res=0;
	for(int i=1;i<5;i++)
	{
		for(int j=1;j<5;j++)
		{
			res+=dp[n][2*t-1][i][j];
		}
	}

	cout<<res;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 500005
typedef long long ll;
/*#ifndef ONLINE_JUDGE
        freopen("1.txt","r",stdin);
#endif */

ll dp[25][15][5][2];///分别表示第i个数，第j个尖峰数，尖峰高度和上升（1）或下降（0）

int main(){
    #ifndef ONLINE_JUDGE
       // freopen("1.txt","r",stdin);
    #endif
    int n,m;
    for(int i=1;i<5;i++) dp[1][1][i][1]=1;
    for(int i=2;i<=20;i++){
        for(int j=1;j<=10;j++){
            for(int k=1;k<=4;k++){
                for(int l=1;l<k;l++){///更新上升的尖峰: 1：下降峰加个上升   2：上升再加一个上升
                    dp[i][j][k][1]+=dp[i-1][j-1][l][0]+dp[i-1][j][l][1];
                }
                if(i==2){///2步不可能的情况
                    dp[i][j][k][0]=0;
                }
                else{
                    for(int l=k+1;l<=4;l++){
                        ///更新下降的尖峰(1:下降峰再加一个下降,2:上升峰加一个下降)
                        dp[i][j][k][0]+=dp[i-1][j][l][0]+dp[i-1][j][l][1];
                    }
                }
            }
        }
    }
    cin>>n>>m;
    ll ans=0;
    for(int i=1;i<=4;i++){
        ans+=dp[n][m][i][0];
    }
    cout<<ans<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ls l,mid,rt<<1
#define rs mid+1,r,rt<<1|1
#define de(x) cout<< #x<<" = "<<x<<endl
#define dd(x) cout<< #x<<" = "<<x<<" "
#define sf scanf
#define pf printf
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef long double ld;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const double PI=acos(-1.0);
const int MAXN=25;
const int MOD=1e9+7;
int sgn(double x){if(fabs(x)<eps)return 0;if(x<0)return -1;else return 1;}
ll pw(ll a,ll n,ll mod){ll ret=1;while(n){if(n&1)ret=ret*a%mod;a=a*a%mod;n>>=1;}return ret;}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
//head

int n,t,lim[MAXN];
ll dp[MAXN][5][MAXN];

void gao(int a,int b,int c){
    if(c&1){
        for(int j=1;j<b;j++)dp[a+1][j][c]+=dp[a][b][c];
        for(int j=b+1;j<=4;j++)dp[a+1][j][c+1]+=dp[a][b][c];
    }else{
        for(int j=1;j<b;j++)dp[a+1][j][c+1]+=dp[a][b][c];
        for(int j=b+1;j<=4;j++)dp[a+1][j][c]+=dp[a][b][c];
    }
}

int main(){
    sf("%d%d",&n,&t);t=2*t-1;
    lim[1]=lim[2]=0;for(int i=3;i<=n;i++)lim[i]=lim[i-1]+1;
    //
    for(int j=1;j<=3;j++)dp[1][j][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=4;j++)
            for(int k=0;k<=min(lim[i],t);k++)
                gao(i,j,k);
    ll ans=0;
    for(int j=1;j<=3;j++)ans+=dp[n][j][t];
    pf("%I64d\n",ans);
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unistd.h>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1E-9
#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define NL printf("\n");
#define RET return
#define CO(x) cout << x;
#define COP(x,p) cout.width(p); cout << x;
#define sqr(x) ((x)*(x))
#define myabs(x) (((x)<0)?(-(x)):(x))

#define VAR(a,T) __typeof(T) a=(T)
#define BEG(c) (c).begin()
#define BEGR(c) (c).rbegin()
#define END(c) (c).end()
#define ENDR(c) (c).rend()
#define ALL(c) BEG(c), END(c)
#define POS(c,x) ((c).find(x) != END(c))
#define CLR(c) memset(c, 0, sizeof(c))
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define SSORT(c) stable_sort(ALL(c))
#define ZERO(i,v) (((i)<0)?(0):(v))
#define MASK(r,c,b) (((r)<<b)+c)
#define REP(i,e) for(int i = 0; i < (e); ++i)
#define REPD(i,e) for(int i = e-1; i >= 0; --i)
#define REPB(i,e) for(int i=0, b=1; i<(signed)(e); ++i, b<<=1)
#define REPS(i,c) for(int i = 0; i < (int) (c).size(); ++i)
#define FORU(i,b,e) for(int i = (b); i <= (signed)(e); ++i)
#define FORD(i,b,e) for(int i = (b); i >= (signed)(e); --i)
#define VELU(it,c) for(VAR(it, BEG(c)); it != END(c); ++it)
#define VELD(it,c) for(VAR(it, BEGR(c)); it != ENDR(c); ++it)
#define TLE FORU(yy,0,1000000000) FORU(xx,0,1000000000) cout << "\n";
#define TCM template <class K,class V>
#define TCT template <class T>
#define V(T) vector<T>

typedef long long LL; typedef long double LD;
typedef unsigned long long ULL;
typedef V(int) vi; typedef V(vi) vvi;
typedef V(char) vc; typedef V(vc) vvc;
typedef V(string) vs; typedef pair<int,int> pii;
typedef istringstream iss; typedef ostringstream oss;

const int INF = (1<<31)-1; const LL INFLL = (1LL<<63)-1;

TCM void SM (const map<K,V> &m,int p=0) {VELU(it,m){COP(it->ST,p)CO(": ")COP(it->ND,p)NL}NL}
TCT void SS (const set<T> &s,int p=0) {VELU(it,s){COP(*it,p)CO(" ")}NL}
TCT void SSP (const set<T> &s,int p=0) {VELU(it,s){COP("("<<(it->ST)<<","<<(it->ND)<<")",p)}NL}
TCT void SV (const V(T) &v,int p=0) {VELU(it,v){COP(*it,p)CO(" ")}NL}
TCT void SVS (const V(T) &v,int p=0) {VELU(it,v){COP(*it,p)}NL}
TCT void SVV (const V(V(T)) &v,int p=0) {VELU(it,v){SVS<T>(*it,p);}NL}

TCT bool OrdAsc (const T &a, const T &b) {return a < b;}
TCT bool OrdDes (const T &a, const T &b) {return a > b;}
TCT bool OrdXY (const T &a, const T &b) {if (a->x==b->x) RET a->y<b->y; RET a->x<b->x;}
TCT bool OrdYX (const T &a, const T &b) {if (a->y==b->y) RET a->x<b->x; RET a->y<b->y;}
TCT string t2s(T x) {ostringstream o; o << x; return o.str();}
TCT T s2t(string s) {istringstream i(s); T x; i>>x; return x;}
TCT inline int size (const T&c) {return c.size();}

vs split (string s, string del = " ") { vs res;
  int ss = s.size(), sdel = del.size();
  for (int p = 0, q; p < ss; p = q+sdel) {
    if ((q = s.find(del, p)) == (signed)string::npos) q = ss;
    if (q-p>0) res.push_back(s.substr(p,q-p));
  } return res;
}

int n,t;
LL DP[21][21][5]; // n,t*2(up,down),y

LL cal(int n, int t, int y){
  if (DP[n][t][y] != -1) return DP[n][t][y];
  if (!n && !t) return 1;
  if (n<=0 || t<=0) return 0;
  LL res = 0;
  if (t%2 == 0) {
    FORU(i,y+1,4) res += cal(n-1, t, i) + cal(n-1, t-1, i);
  } else FORD(i,y-1,1) res += cal(n-1, t, i) + cal(n-1, t-1, i);
  return DP[n][t][y] = res;
}

int main() {
  memset(DP, -1, sizeof(DP));
  scanf("%d %d\n", &n, &t);
  long long ans = 0;
  for (int i = 4; i; i--) ans += cal(n-1, 2*t, i);
  cout << ans << endl;
  return 0;
}

//gskhirtladze

#include<iostream>
#include<stdio.h>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<time.h>
#include<queue>
#include<fstream>
#include<string>
#include<stack>
//#include<conio.h>

#define ex 0.000000001
#define pii 3.1415926535897932
#define m9 1000000009
#define m7 1000000007
#define minm(aa,bb)(aa>bb)?bb:aa
#define maxx(aa,bb)(aa<bb)?bb:aa

using namespace std;

long long m,t,i1,i2,res,dp[5][5][22][12][12];

long long df(long long y1, long long y2, long long n, long long in, long long out)
 {
  long long& res=dp[y1][y2][n][in][out];
  if (res!= -1) return res;
  if (n>m)
   {
    if (in==0&&out==0)
     return res=1; else return res=0;
   }
  res=0;
  for(long long y3=1;y3<=4;y3++)
   {
   if (y3==y2) continue;
   if (y3>y2)
   {
    if (y2>y1) res+=df(y2,y3,n+1,in,out); else
    if (y1>y2 && out>0) res+=df(y2,y3,n+1,in,out-1);
   }
   else
   {
    if (y2>y1 && in>0) res+=df(y2,y3,n+1,in-1,out); else
    if (y1>y2) res+=df(y2,y3,n+1,in,out);
   }
  }
  return res;
}

main()
{
 int j1,j2,j3,j4,j5;
 for (int j1=0;j1<=4;j1++)
  for (int j2=0;j2<=4;j2++)
   for (int j3=0;j3<=21;j3++)
    for (int j4=0;j4<=11;j4++)
     for (int j5=0;j5<=11;j5++)
      dp[j1][j2][j3][j4][j5]=-1;
 cin>>m>>t;
 for(i1=1;i1<=4;i1++)
  for(i2=1;i2<=4;i2++)
   {
    if (i1==i2) continue;
    res+=df(i1,i2,3,t,t-1);
   }
 cout<<res<<endl;
}

#include<iostream>
#include<cstdio>

#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>

#include<iomanip>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<cassert>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define correct(x, y, n, m) (0 <= x && x < n && 0 <= y && y < m)
#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define next n_ext
#define sz(v) (int)(v.size())

template<typename T> inline T abs(T a){ return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a){ return a * a; }

typedef long long li;
typedef unsigned long long uli;
typedef long double ld;
typedef pair<int, int> pt;

const int N = 209;
const int M = 8;
const int sqrN = 450;
const int MOD = 1000000007;
const int INF = 1e9;
const li INF64 = 1e18;
const ld PI = 3.1415926535897932384626433832795;
const ld eps = 1e-9;

int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};

int n, k;
li dp[23][5][5][23][23];

li calc_dp(int pos, int l2, int l1, int g, int ng){
    li &res = dp[pos][l2][l1][g][ng];
    if(res != -1)
        return res;

    if(pos == n)
        return res = (g == k && ng == k - 1);

    res = 0;
    if(l1 == 0){
        for(int i = 1; i <= 4; ++i)
            res += calc_dp(pos + 1, l1, i, g, ng);
        return res;
    }
    if(l2 == 0){
        for(int i = 1; i <= 4; ++i)
            if(i != l1)
                res += calc_dp(pos + 1, l1, i, g, ng);
        return res;
    }

    for(int i = 1; i <= 4; ++i)
        if(i != l1){
            if(l1 < i && l1 < l2)
                res += calc_dp(pos + 1, l1, i, g, ng + 1);
            else
                if(l1 > i && l1 > l2)
                    res += calc_dp(pos + 1, l1, i, g + 1, ng);
                else
                    res += calc_dp(pos + 1, l1, i, g, ng);
        }
        return res;
}

int main(){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    srand(time(NULL));
    cout << setprecision(10) << fixed;
    cerr << setprecision(10) << fixed;

    cin >> n >> k;

    memset(dp, -1, sizeof dp);
    cout << calc_dp(0, 0, 0, 0, 0);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 20 + 5;

int dp[maxn][maxn][maxn][2]; // i位置，j高度，k个峰顶，上升/下降

int main() {
    int n, t;
    scanf("%d%d", &n, &t);
    dp[2][4][0][0] = 3;
    dp[2][3][0][0] = 2;
    dp[2][2][0][0] = 1;
    for (int i = 3; i <= n; i++) {
        for (int k = 0; k <= t; k++) {
            for (int j = 1; j <= 4; j++) {
                for (int l = 1; l <= 4; l++) {
                    if (l < j) dp[i][j][k][0] += dp[i - 1][l][k][0] + dp[i - 1][l][k][1];
                    if (l > j) dp[i][j][k][1] += dp[i - 1][l][k][1] + (k > 0 ? dp[i - 1][l][k - 1][0] : 0);
                }
            }
        }
    }
    int res = 0;
    for (int i = 1; i <= n; i++) res += dp[n][i][t][1];
    printf("%d\n", res);
    return 0;
}

// https://www.cnblogs.com/BaseAI/p/11744246.html
//hellobig_tq//hellobig_tq

#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

int dp[30][20][2][10];

int go(int n, int t, int dir, int curr) {
	if (dp[n][t][dir][curr] != -1) return dp[n][t][dir][curr];
	if (t < 0) return 0;
	if (n == 1) return (t == 0 && dir == 0);
	int ans = 0;
	if (dir) {
		for (int i = curr + 1; i <= 4; i++) {
			ans += go(n - 1, t, 1, i);
			if (n > 2) ans += go(n - 1, t, 0, i);
		}
	} else {
		for (int i = curr - 1; i >= 1; i--) {
			if (n > 2) ans += go(n - 1, t - 1, 1, i);
			ans += go(n - 1, t, 0, i);
		}
	}
	return dp[n][t][dir][curr] = ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	memset(dp, -1, sizeof dp);
	int n, t; cin >> n >> t;
	int ans = 0;
	for (int i = 1; i <= 4; i++)
		ans += go(n, t - 1, 1, i);
	cout << ans << endl;
	return 0;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define pb push_back
#define sz size()
#define x first
#define y second
#define MAXN
#define REP(i,n) for ((i)=1;(i)<(n);(i)++)
typedef pair<int,int>pii;
const int oo=(int)1e9;

typedef long long ll;
int n,t;
ll f[21][11][11][5][2];

ll dp(int x,int y,int k,int z,int z2){
    if (x==n){
        if (y==t && k==t-1 && z2==0){
            return 1;
        }
        return 0;
    }
    ll res;
    res=0;
    if (f[x][y][k][z][z2]!=-1) return f[x][y][k][z][z2];
    if (z==0){
        for (int i=1;i<=4;i++){
            res+=dp(x+1,y,k,i,1);
            //cout<<dp(x+1,y,k,i,1)<<endl;
        }
    }
    else {
        for (int i=1;i<z;i++){
            if (z2==1){
                if (y+1<=t && x>1){
                    res+=dp(x+1,y+1,k,i,0);
                }
                else res+=dp(x+1,y,k,i,0);
            }
            else res+=dp(x+1,y,k,i,0);
        }
        for (int i=z+1;i<=4;i++){
            if (z2==0){
                if (k+1<=t-1){
                    res+=dp(x+1,y,k+1,i,1);
                }
            }
            else res+=dp(x+1,y,k,i,1);
        }
    }
    return f[x][y][k][z][z2]=res;
}

int main(){
    scanf("%d%d",&n,&t);
    memset(f,-1,sizeof(f));
    printf("%lld\n",dp(0,0,0,0,0));
    return 0;
}

# include <stdio.h>
# include <stdlib.h>
# include <iostream>

using namespace std;

# define MAX 30

// 0 ABAJO
// 1 ARRIBA

long long DP[ MAX ][ MAX ][ MAX ][ 2 ];

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	long long N, T, SOLUTION = 0;
	cin >> N >> T;

	for( int i = 1 ; i <= N ; i++ ){

		// Base case //
		for( int t = 0 ; t <= T ; t++ ){

			for( int h = 1 ; h <= 4 ; h ++ ){

				if( i == 1 && t == 0 ){
					DP[ i ][ t ][ h ][ 0 ] = 1;
					DP[ i ][ t ][ h ][ 1 ] = 1;
				}else if( i > 0 ){

					for( int k = 1; k <= 4 ; k ++ ){

						if( k > h ){

							DP[ i ][ t ][ h ][ 1 ] += DP[ i - 1 ][ t ][ k ][ 1 ];

							if( t > 0 && i >= 3 )
								DP[ i ][ t ][ h ][ 1 ] += DP[ i - 1 ][ t - 1 ][ k ][ 0 ];

						}else if( k < h ){
							DP[ i ][ t ][ h ][ 0 ] += DP[ i - 1 ][ t ][ k ][ 0 ];
							if( t > 0 && i > 2 )
								DP[ i ][ t ][ h ][ 0 ] += DP[ i - 1 ][ t ][ k ][ 1 ];
						}

					}

				}

				//cout << i << " " << t << " " << h << " " << DP[ i ][ t ][ h ][ 0 ] << " " << DP[ i ][ t ][ h ][ 1 ] << endl;
				//getchar();

				if( i == N && T == t ){
					SOLUTION += DP[ i ][ t ][ h ][ 1 ];
				}

			}

		}

	}

	cout << SOLUTION << endl;

	return 0;
}

#include<bits/stdc++.h>
#define MAX 20+10
#define INF 10000000
#define B 13
#define x(z) z.first
#define y(z) z.second
#define memo(x,y) memset(x,y,sizeof(x))
#define mp(a,b) make_pair(a,b)
#define fscan ios::sync_with_stdio(false) ,cin.tie(0)
using namespace std  ;
int dp[MAX][5][5][11][11] ,n , t;
bool v[MAX][5][5][11][11] ;

int solve(int idx,int pp,int p,int ups,int dwns)
{

    if(p < 1 || p > 4 || ups > t || idx > n)
    return 0 ;

    if(idx == n && ups == t && dwns == t-1)
    return 1 ;

    if(idx == n)
    return 0 ;

    if(v[idx][pp][p][ups][dwns])
    return dp[idx][pp][p][ups][dwns] ;

    if(pp<p)
    dp[idx][pp][p][ups][dwns] += solve(idx+1,p,p+1,ups,dwns) + solve(idx+1,p,p+2,ups,dwns) + solve(idx+1,p,p+3,ups,dwns) ;

    if(pp<p)
    dp[idx][pp][p][ups][dwns] += solve(idx+1,p,p-1,ups+1,dwns) + solve(idx+1,p,p-2,ups+1,dwns) + solve(idx+1,p,p-3,ups+1,dwns) ;

    if(pp>p)
    dp[idx][pp][p][ups][dwns] += solve(idx+1,p,p+1,ups,dwns+1) + solve(idx+1,p,p+2,ups,dwns+1) + solve(idx+1,p,p+3,ups,dwns+1) ;

    if(pp>p)
    dp[idx][pp][p][ups][dwns] += solve(idx+1,p,p-1,ups,dwns) + solve(idx+1,p,p-2,ups,dwns) + solve(idx+1,p,p-3,ups,dwns) ;

    v[idx][pp][p][ups][dwns] = true ;

    return dp[idx][pp][p][ups][dwns] ;
}

int main()
{
    //freopen("","r",stdin) ;
    //freopen("","w",stdout) ;
    fscan ;
    int x = 0 ;
    cin >> n >> t ;
    for(int i =1 ;i<=4;i++)
        for(int j = 1 ;j<=4;j++)
            if(i==j)continue ;
            else x += solve(2,i,j,0,0) ;
    cout << x << endl ;
    return 0 ;
}

/*
 this code was written by Zanaty
 problem kind:
 */
#include<iostream>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<stdio.h>
#include<set>
#include<cmath>
#include<fstream>
#include<memory.h>
#include<map>
#include<sstream>
#include<climits>/*
#include <ext/hash_set>
#include <ext/hash_map>
using namespace __gnu_cxx;
*/
using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define reps(i,x,n) for((i)=(x);(i)<(int)(n);(i)++)
#define repi(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define SZ(v) (int)v.size()
#define mp(x,y) make_pair(x,y)
#define ll long long
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define INF (int)10e8
#define MAX (int) 10e6

int dp[21][11][5][2];

int f(int n, int t, int lst, bool tal3, string s) {

    if (n == 0 && t == 0 && !tal3) {
//      cout <<"RES: "<< s << endl;
        return 1;
    }
    if (n == 0)
        return 0;

//  cout << n << " " << t << " " << lst << " " << tal3 << endl;

    int &res = dp[n][t][lst][tal3];

    if (res != -1)
        return res;

    res = 0;
    for (int i = lst + 1; i < 5; i++) {
        res += f(n - 1, t, i, 1, s + (char) (i + '0'));
//      cout<<endl;
    }

    for (int i = lst - 1; i > 0; i--) {
        res += f(n - 1, t - tal3, i, 0, s + (char) (i + '0'));
//      cout<<endl;
    }

    return res;

}

int main() {
#ifndef ONLINE_JUDGE
    freopen("test.txt", "r", stdin);
#endif

    int n, t;

    scanf("%d %d", &n, &t);

    memset(dp, -1, sizeof dp);

    int res = 0;
    for (int i = 1; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
//          cout << "FIRST ELEMENTOOO:  " << i<<"  "<<j << endl;
            res += f(n - 2, t, j, 1, "");
        }
    }
    cout << res << endl;

    return 0;
}

/**
 *
 *
 *  http://codeforces.com/problemset/problem/14/E
 *
 *
 */

#include <bits/stdc++.h>

#define Nmax int(20+10)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<string> vs;

int n, t;
ll f[Nmax][30][4];

void sol(){
    cin >> n >> t;
    t += t+1;
    f[0][0][0]=f[0][0][1]=f[0][0][2]=1;
    for(int i=1; i<n; i++){
        for(int tt=1; tt<=i; tt++){
            for(int k=0; k<4; k++){
                if(tt%2==0){
                    for(int j=k+1; j<4; j++){
                        f[i][tt][k]+= f[i-1][tt][j];
                        f[i][tt][k]+= f[i-1][tt-1][j];
                    }
                }
                if(tt%2==1){
                    for(int j=0; j<k; j++){
                        f[i][tt][k]+= f[i-1][tt][j];
                        f[i][tt][k]+= f[i-1][tt-1][j];
                    }
                }
            }
        }
    }

    ll res= 0;
    for(int i=0; i<4; i++) res+= f[n-1][t-1][i];

    cout << res << "\n";
}

int main(){

	std::ios::sync_with_stdio(false);
	cin.tie(NULL);

    sol();

    return 0;
}

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <fstream>
#include <algorithm>

using namespace std;

long long n,t;
long long f[22][22][22][22][22];

int main()
          {
             //freopen("input.txt","r",stdin);
             //freopen("output.txt","w",stdout);
             cin >> n >> t;
             for (long long i = 1; i<=4; i++)
              for (long long j = 1; j<=4; j++)
               if (i!=j)
               f[2][i][j][0][0]=1;
              for (long long i = 3; i<=n; i++)
               for (long long val = 1; val<=4; val++)
                 for (long long pr1 = 1; pr1<=4; pr1++)
                  for (long long pr2 = 1; pr2<=4; pr2++)
                    for (long long cnt1 = 0; cnt1<=t; cnt1++)
                     for (long long cnt2 = 0; cnt2<=t; cnt2++)
                      {
                               if (pr2==val) continue;
                               if (f[i-1][pr1][pr2][cnt1][cnt2]==0) continue;
                               int q1,q2;
                               if (pr2>pr1 && pr2>val) q1=1; else q1=0;
                               if (pr2<pr1 && pr2<val) q2=1; else q2=0;
                               q1=q1+cnt1; q2=q2+cnt2;
                               f[i][pr2][val][q1][q2]+=f[i-1][pr1][pr2][cnt1][cnt2];
                      };
                 long long answer = 0;
                 for (long long i1 = 1; i1<=4; i1++)
                  for (long long i2 = 1; i2<=4; i2++)
                   {
                           if (i1==i2) continue;
                           answer+=f[n][i1][i2][t][t-1];
                   };
                 cout << answer << endl;
             return 0;
          };

#include "cstdio"
#include "cstring"
using namespace std;
typedef long long i64;

i64 memo[21][11][11][5][5];
bool mark[21][11][11][5][5];

i64 f(int n, int nmax, int nmin, int h1, int h2) {
  if (h1 < 1 || h1 > 4 || h2 < 1 || h2 > 4) return 0;
  if (nmax < 0 || nmin < 0 || h1 == h2) return 0;
  if (n == 0) return nmax == 0 && nmin == 0 ? 1 : 0;
  i64& count = memo[n][nmax][nmin][h1][h2];
  if (mark[n][nmax][nmin][h1][h2]) return count;
  count = 0, mark[n][nmax][nmin][h1][h2] = true;
  for (int h3 = 1; h3 <= 4; ++h3) {
    int nnmax = nmax, nnmin = nmin;
    if (h1 < h2 && h2 > h3) --nnmax;
    if (h1 > h2 && h2 < h3) --nnmin;
    count += f(n - 1, nnmax, nnmin, h2, h3);
  }
  return count;
}
int main() {
  int n, t; scanf("%d %d", &n, &t);
  memset(mark, false, sizeof(mark));
  i64 total = 0;
  for (int h1 = 1; h1 <= 4; ++h1)
    for (int h2 = h1 + 1; h2 <= 4; ++h2)
      total += f(n - 2, t, t - 1, h1, h2);
  printf("%I64d\n", total);
  return 0;
}

// for challenge test
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int dp[22][4][22];
int main()
{
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=3;i++)
    dp[1][i][0]=1;
    for(int x=2;x<22;x++)
    for(int y=1;y<=4;y++)
    for(int t=0;t<21;t++)
    for(int h=1;h<=4;h++)
    {
        if(x==2)
        {
            if(y>h)
            {
                if(t%2)
                dp[2][y][t+1]+=dp[1][h][t];
                else
                dp[2][y][t]+=dp[1][h][t];
            }
                }
        else
            {
                if(t%2)
            {
                if(h>y)
                dp[x][y][t]+=dp[x-1][h][t];
                else if(h<y)
                dp[x][y][t+1]+=dp[x-1][h][t];
            }
            else
            {
                if(h<y)
                dp[x][y][t]+=dp[x-1][h][t];
                else if(h>y)
                dp[x][y][t+1]+=dp[x-1][h][t];
            }
            }
    }
    int n,t;
    while(cin>>n>>t)
    {
        if(1+2*t>n||n>6*t+1) {cout<<"0"<<endl;continue;}
        int ans=0;
        for(int i=1;i<=4;i++)
        ans+=dp[n][i][2*t-1];
    cout<<ans<<endl;
    }
    return 0;
}

#include <iostream>
#define maxn 20
#define maxt 10
#define maxh 4

using namespace std;

int n, t;

long long mas[maxt+1][maxn+1][maxh+1];

long long facts[2*maxh + 2];

void fill_facts()
{
    facts[0] = 1;
    for (int i = 1; i <= 2*maxh + 1; ++i)
        facts[i] = i*facts[i-1];
}

long long C(int n, int k)
{
    if (n < k)
        return 0;
    else return facts[n]/(facts[n-k]*facts[k]);
}

long long solve1(int ti, int li, int hi)
{
    if (mas[ti][li][hi] >= 0)
        return mas[ti][li][hi];

    if (ti == 0 && li == 1)
        return (mas[ti][li][hi] = 1);

    if (li < 3 || hi == maxh || ti == 0)
        return mas[ti][li][hi] = 0;

    mas[ti][li][hi] = 0;
    // 4 - hi x li - 2 -- all pts for spike

    // spl = 1, is the starting point
    long long c1, c2;
    for (int spl = 2; spl <= li - 1; ++spl)
        for (int sph = hi + 1; sph <= maxh; ++sph)
        {
            //C(sph - hi - 1, spl - 2)
            // some spikes cannot be, which ones?
            c1 = C(sph - hi - 1, spl - 2);
            // spike coords (spl, sph), going down now
            for (int dl = spl + 1; dl <= li; ++dl)
                for (int dh = 1; dh <= sph - 1; ++dh)
                {
                    //C(sph - dh - 1, dl - spl - 1)
                    c2 = C(sph - dh - 1, dl - spl - 1);
//                    cout << c1 << " " << c2 << endl;
                    mas[ti][li][hi] += c1*c2*solve1(ti - 1, li - dl + 1, dh);
                }
        }
    return mas[ti][li][hi];
}

int main()
{
    cin >> n >> t;
    long long res = 0;
    fill_facts();

    for (int i = 0; i <= maxt; ++i)
        for (int j = 0; j <= maxn; ++j)
            for (int k = 0; k <= maxh; ++k)
                mas[i][j][k] = -1;

    for (int hi = 1; hi <= maxh; ++hi)
    {
        res += solve1(t, n, hi);
        //        cout << res << " " << hi << endl;
    }

    cout << res << endl;

    return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef vector<int> vint;
typedef long long lint;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

int dp[22][22][22][4][2];

int main() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	/*for(int y = 0; y < 4; ++y) {
		dp[0][0][0][y][0] = 1;
	}*/
	dp[1][0][0][0][0] = 3;
	dp[1][0][0][0][1] = 0;

	dp[1][0][0][1][0] = 2;
	dp[1][0][0][1][1] = 1;

	dp[1][0][0][2][0] = 1;
	dp[1][0][0][2][1] = 2;

	dp[1][0][0][3][0] = 0;
	dp[1][0][0][3][1] = 3;
	for(int x = 1; x < 20; ++x) {
		for(int i = 0; i < 20; ++i) {
			for(int j = 0; j < 20; ++j) {
				for(int y = 0; y < 4; ++y) {
					for(int up = 0; up < 2; ++up) {
						if(dp[x][i][j][y][up] == 0) {
							continue;
						}
						//cout << dp[x][i][j][y][up] << endl;
						for(int ny = 0; ny < 4; ++ny) {
							if(y == ny)
								continue;
							int nup = ny > y ? 1 : 0;
							/*if(x == 1) {
								dp[x + 1][i][j][ny][nup] += dp[x][i][j][y][up];
								continue;
							}*/
							int ni = i;
							int nj = j;
							if(nup > up) {
								nj++;
							}
							if(nup < up) {
								ni++;
							}
							dp[x + 1][ni][nj][ny][nup] += dp[x][i][j][y][up];
						}
					}
				}
			}
		}
	}
	int n, t;
	scanf("%d %d", &n, &t);
	int ans = 0;
	for(int y = 0; y < 4; ++y) {
		//for(int up = 0; up <= 1; ++up)
			ans += dp[n - 1][t][t - 1][y][0];
	}
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 22;
const int MAX_T = 12;

unsigned long long dp[MAX_N][MAX_T][MAX_T][4][4];
int n , t;

int main () {
    scanf("%d %d" , &n , &t);

    for (int x = 0; x < 4; x++)
        for (int y = 0; y < 4; y++)
            if (x != y) dp[2][0][0][x][y] = 1;

    for (int i = 3; i <= n; i++)
        for (int a = 0; a <= t; a++)
            for (int b = 0; b <= t; b++)
                for (int x = 0; x < 4; x++)
                    for (int y = 0; y < 4; y++)
                        for (int z = 0; z < 4; z++)
                            if (z != x) {
                                if (x < y) {
                                    if (z > x) {
                                        if (!b) continue;
                                        dp[i][a][b][x][y] += dp[i - 1][a][b - 1][z][x];
                                    }
                                    else dp[i][a][b][x][y] += dp[i - 1][a][b][z][x];
                                }
                                else
                                if (x > y) {
                                    if (z < x) {
                                        if (!a) continue;
                                        dp[i][a][b][x][y] += dp[i - 1][a - 1][b][z][x];
                                    }
                                    else dp[i][a][b][x][y] += dp[i - 1][a][b][z][x];
                                }
                            }

    unsigned long long res = 0LL;

    for (int x = 0; x < 4; x++)
        for (int y = 0; y < 4; y++)
            if (x != y) res += dp[n][t][t - 1][x][y];

    printf("%I64d" , res);
    return 0;
}

/* Author : RISHAV GOYAL */

#include <bits/stdc++.h>

using namespace std;

#define LL long long int
#define UL unsigned long long int

#define imax INT_MAX
#define imin INT_MIN
#define LLmax LLONG_MAX
#define LLmin LLONG_MIN

#define FOR(i,a,b) for(int i= (int)a; i<= (int)b; i++)
#define rep(i,n) for(int i= int(1); i<= (int)n; i++)
#define FORd(i,a,b,d) for(int i=(int)a; i<= (int)b; i+=(int)d)

#define pr() printf("Reached here 1...\n");
#define pr1() printf("Reached here 2...\n");

#define CLR(a) memset(a,0,sizeof(a));
#define SET(a) memset(a,-1,sizeof(a));

#define str strlen
#define pb(x) push_back(x)
#define mp make_pair
#define ii pair<int,int>
#define ll pair<LL,LL>
#define F first
#define S second
#define gcd(a,b) __gcd(a,b)

#define mod int(1e9 +7)
#define MAX int(1e5 + 10)

#define si(a) scanf("%d",&a);

#define VI vector<int>
#define VL vector<LL>
#define VS vector<string>
#define VC vector<char>

LL powmod(LL a,int b,int n){LL rm=1;while (b){if (b % 2) { rm = (rm * a) % n; }a = (a * a) % n;b /= 2;}return rm;}

LL dp[30][12][12][2][5] ={0} ; // [i][t+][t-][/\][1..4];
int n,t;

int main()
{
	cin >> n >> t;

	dp[2][0][0][0][2] = 1;
	dp[2][0][0][0][3] = 2;
	dp[2][0][0][0][4] = 3;

	dp[2][0][0][1][3] = 1;
	dp[2][0][0][1][2] = 2;
	dp[2][0][0][1][1] = 3;

	for(int i=3;i<=n;++i){
		for(int j=0;j<=t;++j){
			for(int k=0;k<=t;++k){
				for(int now=1;now<=4;++now){
					for(int prv = 1; prv <= 4; ++ prv){
						if(prv > now){
							if(j) dp[i][j][k][1][now] += dp[i-1][j-1][k][0][prv];
						}
					}
				}
				for(int now = 1; now <= 4;++ now){
					for(int prv = 1; prv <=4 ;++ prv){
						if(prv < now){
							if(k) dp[i][j][k][0][now] += dp[i-1][j][k-1][1][prv];
						}
					}
				}
				for(int now = 1; now <=4 ; ++ now){
					for(int prv = 1 ; prv <= 4;++prv){
						if(prv > now){
							dp[i][j][k][1][now] += dp[i-1][j][k][1][prv];
						}
					}
				}
				for(int now = 1; now <= 4;++ now){
					for(int prv = 1; prv <= 4;++ prv){
						if( prv < now ){
							dp[i][j][k][0][now] += dp[i-1][j][k][0][prv];
						}
					}
				}
				 //for(int now=1;now<5;++now) cout << i << " " << j << " " << k <<" " << now<<" / "<<dp[i][j][k][0][now]<<endl;
				 //for(int now=1;now<5;++now) cout << i << " " << j << " " << k <<" " << now<<" ]] " <<dp[i][j][k][1][now]<<endl;
			}
		}
	}
	LL ans = 0 ;
	for(int i=0;i<=1;++i){
		for(int j=1;j<=4;++j){
			ans += dp[n][t][t-1][i][j];
		}
	}
	cout << ans << endl;
	return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAXH  = 5;
const int MAXM  = 11;
const int MAXN  = 21;

int n, t;

int f[MAXN][MAXM][MAXH][MAXH];

bool Input(void) {
        if( EOF == scanf("%d %d", &n, &t) ) {
                return false;
        }
        return true;
}

inline int Opt(int len, int cnt, int HL, int HR) {
        int &ans = f[len][cnt][HL][HR];
        if( -1 != ans ) {
                return ans;
        }

        // if( HR-HL+1 < 2*cnt+1 ) {
        //         return ans = 0;
        // }
        if( 1 == cnt ) {
                ans = 0;
                for(int topIdx = 2; topIdx < len; topIdx ++) {
                        for(int topH = 2; topH <= 4; topH ++) {
                                int tmp = 0;
                                if( topIdx-1 > topH-HL || len-topIdx > topH-HR )  {
                                        continue;
                                }
                                if( topIdx-1 == 2 && topH-HL == 3 ) {
                                        tmp += 2;
                                }
                                if( len-topIdx == 2 && topH-HR == 3 ) {
                                        tmp += 2;
                                }
                                if( !tmp ) {
                                        tmp += 1;
                                }
                                ans += tmp;
                        }
                }
                //printf("f[%d][%d][%d][%d] = %d\n", len, cnt, HL, HR, ans);
                return ans;
        }

        ans = 0;
        for(int k = 1; k < len; k ++) {
                for(int L = 1; L <= 4; L ++) {
                        ans += Opt(len-k, cnt-1, HL, L)*Opt(k+1, 1, L, HR);
                }
        }
        //printf("f[%d][%d][%d][%d] = %d\n", len, cnt, HL, HR, ans);
        return ans;
}

int Process(void) {
        int ans = 0;
        //printf("n = %d, t = %d\n", n, t);
        for(int hl = 1; hl <= 4; hl ++) {
                for(int hr = 1; hr <= 4; hr ++) {
                        ans += Opt(n, t, hl, hr);
                }
        }
        return ans;
}

int main(int argc, char const *argv[])
{
        //freopen("test.in", "r", stdin);
        memset(f, -1, sizeof(f));
        while( true == Input() ) {
                printf("%d\n", Process());
        }
        return 0;
}

#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <hash_map>
#include <functional>
#include <sstream>
#include <stack>
#include <iterator>
using namespace std;

const double eps = 1e-10;

__int64 dp[20][19][4];
int n = 0, t = 0;
int T = 0;

__int64 calc(int cur_n, int cur_t, int cur_h)
{
	if (cur_n == n - 1) {
		if (cur_t == T) {
			return 1;
		} else {
			return 0;
		}
	}
	if (cur_t > T) {
		return 0;
	}
	if (dp[cur_n][cur_t][cur_h] != -1) {
		return dp[cur_n][cur_t][cur_h];
	}
	__int64 result = 0;
	if (cur_t % 2 == 0) {// ��������� ����� ��� ��������.
		for (int h = cur_h + 1; h < 4; h++) { // ���������� �����.
			result += calc(cur_n + 1, cur_t, h);
		}
		for (int h = cur_h - 1; h >= 0 && cur_n != 0; h--) { // �����, ����, ���� ����.
			result += calc(cur_n + 1, cur_t + 1, h);
		}
	}
	else { // ��� ����.
		for (int h = cur_h - 1; h >= 0; h--) { // ���������� ����.
			result += calc(cur_n + 1, cur_t, h);
		}
		for (int h = cur_h + 1; h < 4; h++) { // �����, �������, ���� �����.
			result += calc(cur_n + 1, cur_t + 1, h);
		}
	}
	dp[cur_n][cur_t][cur_h] = result;
	return result;
}

int main()
{
	cin >> n >> t;
	T = 2 * t - 1;// ����� �������.
	memset(dp, -1, sizeof dp);
	__int64 result = 0;
	for (int i = 0; i < 4; i++) {
		dp[0][0][i] = calc(0, 0, i);
		result += dp[0][0][i];
	}
	cout << result;
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
using namespace std;
#ifndef ONLINE_JUDGE
#define reop(in) freopen(in, "r", stdin);
#define log_time printf("\n\nTime: %d ms...\n", clock())
#else
#define reop(in)
#define log_time
#endif
#define lolo long long
#define sqr(x) (x) * (x)

const int DSIZE = 21;

int d1[DSIZE][5];
lolo pref_cnt(lolo len, lolo h) {
    for (int i = 0; i < DSIZE; i++) memset(d1[i], 0, sizeof(d1[i]));
    for (int i = 1; i <= 3; i++) d1[0][i] = 1;
    for (int i = 1; i <= len; i++) for (int j = 2; j <= 4; j++) for (int k = 1; k < j; k++) d1[i][j] += d1[i - 1][k];
    return d1[len][h];
}

int d2[DSIZE][5];
lolo suff_cnt(lolo len, lolo h) {
    for (int i = 0; i < DSIZE; i++) memset(d2[i], 0, sizeof(d2[i]));
    d2[0][h] = 1;
    for (int i = 1; i <= len; i++) for (int j = 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) d2[i][j] += d2[i - 1][k];
    lolo ans = 0;
    for (int i = 1; i <= 4; i++) ans += d2[len][i];
    return ans;
}

int d3[DSIZE][4][DSIZE][5];
lolo mid_cnt(lolo cnt, lolo t, lolo st_h, lolo fin_h) {
    for (int i = 0; i < DSIZE; i++) for (int j = 0; j < 4; j++) for (int k = 0; k < DSIZE; k++) memset(d3[i][j][k], 0, sizeof(d3[i][j][k]));
    // 0 - just peak, 1 - just pit, 2 - down, 3 - up
    t = t + t - 1;
    d3[0][0][1][st_h] = 1;
    for (int i = 1; i < cnt; i++)
        for (int tt = 1; tt <= t; tt++) {
            // state 0
            for (int j = 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) d3[i][2][tt][j] += d3[i - 1][0][tt][k];
            for (int j = 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) d3[i][1][tt][j] += d3[i - 1][0][tt - 1][k];

            // state 1
            for (int j = 2; j <= 4; j++) for (int k = 1; k < j; k++) d3[i][3][tt][j] += d3[i - 1][1][tt][k];
            for (int j = 2; j <= 4; j++) for (int k = 1; k < j; k++) d3[i][0][tt][j] += d3[i - 1][1][tt - 1][k];

            // state 2
            for (int j = 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) d3[i][2][tt][j] += d3[i - 1][2][tt][k];
            for (int j = 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) d3[i][1][tt][j] += d3[i - 1][2][tt - 1][k];

            // state 3
            for (int j = 2; j <= 4; j++) for (int k = 1; k < j; k++) d3[i][3][tt][j] += d3[i - 1][3][tt][k];
            for (int j = 2; j <= 4; j++) for (int k = 1; k < j; k++) d3[i][0][tt][j] += d3[i - 1][3][tt - 1][k];
        }
    return d3[cnt - 1][0][t][fin_h];
}

lolo get_ans(lolo n, lolo t, lolo st, lolo fin) {
    if (st > 4) return 0;
    lolo pref = st - 1, suff = n - fin, ans = 0;
    if (fin > n - 1) return 0;
    for (int pref_h = 2; pref_h <= 4; pref_h++)
        for (int suff_h = 2; suff_h <= 4; suff_h++)
            ans += pref_cnt(pref, pref_h) * suff_cnt(suff, suff_h) * mid_cnt(fin - st + 1, t, pref_h, suff_h);
    return ans;
}

int main() {
    reop("in.txt");

    int n = 0, t = 0; scanf("%d%d", &n, &t);
    lolo ans = 0;
    for (int i = 2; i <= n - 1; i++) for (int j = i; j <= n - 1; j++) ans += get_ans(n, t, i, j);
    printf("%I64d\n", ans);

    log_time;
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
using namespace std;
#ifndef ONLINE_JUDGE
#define reop(in) freopen(in, "r", stdin);
#define log_time printf("\n\nTime: %d ms...\n", clock())
#else
#define reop(in)
#define log_time
#endif
#define lolo long long
#define sqr(x) (x) * (x)

const int DSIZE = 21;

int d1[DSIZE][5];
int pref_cnt(int len, int h) {
    for (int i = 0; i < DSIZE; i++) memset(d1[i], 0, sizeof(d1[i]));
    for (int i = 1; i <= 3; i++) d1[0][i] = 1;
    for (int i = 1; i <= len; i++) for (int j = 2; j <= 4; j++) for (int k = 1; k < j; k++) d1[i][j] += d1[i - 1][k];
    return d1[len][h];
}

int d2[DSIZE][5];
int suff_cnt(int len, int h) {
    for (int i = 0; i < DSIZE; i++) memset(d2[i], 0, sizeof(d2[i]));
    d2[0][h] = 1;
    for (int i = 1; i <= len; i++) for (int j = 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) d2[i][j] += d2[i - 1][k];
    int ans = 0;
    for (int i = 1; i <= 4; i++) ans += d2[len][i];
    return ans;
}

int d3[DSIZE][4][DSIZE][5];
int mid_cnt(int cnt, int t, int st_h, int fin_h) {
    for (int i = 0; i < DSIZE; i++) for (int j = 0; j < 4; j++) for (int k = 0; k < DSIZE; k++) memset(d3[i][j][k], 0, sizeof(d3[i][j][k]));
    // 0 - just peak, 1 - just pit, 2 - down, 3 - up
    t = t + t - 1;
    d3[0][0][1][st_h] = 1;
    for (int i = 1; i < cnt; i++)
        for (int tt = 1; tt <= t; tt++) {
            // state 0
            for (int j = 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) d3[i][2][tt][j] += d3[i - 1][0][tt][k];
            for (int j = 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) d3[i][1][tt][j] += d3[i - 1][0][tt - 1][k];

            // state 1
            for (int j = 2; j <= 4; j++) for (int k = 1; k < j; k++) d3[i][3][tt][j] += d3[i - 1][1][tt][k];
            for (int j = 2; j <= 4; j++) for (int k = 1; k < j; k++) d3[i][0][tt][j] += d3[i - 1][1][tt - 1][k];

            // state 2
            for (int j = 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) d3[i][2][tt][j] += d3[i - 1][2][tt][k];
            for (int j = 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) d3[i][1][tt][j] += d3[i - 1][2][tt - 1][k];

            // state 3
            for (int j = 2; j <= 4; j++) for (int k = 1; k < j; k++) d3[i][3][tt][j] += d3[i - 1][3][tt][k];
            for (int j = 2; j <= 4; j++) for (int k = 1; k < j; k++) d3[i][0][tt][j] += d3[i - 1][3][tt - 1][k];
        }
    return d3[cnt - 1][0][t][fin_h];
}

int get_ans(int n, int t, int st, int fin) {
    if (st > 4) return 0;
    int pref = st - 1, suff = n - fin, ans = 0;
    if (fin > n - 1) return 0;
    for (int pref_h = 2; pref_h <= 4; pref_h++)
        for (int suff_h = 2; suff_h <= 4; suff_h++)
            ans += pref_cnt(pref, pref_h) * suff_cnt(suff, suff_h) * mid_cnt(fin - st + 1, t, pref_h, suff_h);
    return ans;
}

int main() {
    reop("in.txt");

    int n = 0, t = 0; scanf("%d%d", &n, &t);
    int ans = 0;
    for (int i = 2; i <= n - 1; i++) for (int j = i; j <= n - 1; j++) ans += get_ans(n, t, i, j);
    printf("%d\n", ans);

    log_time;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define pii pair<ll, ll>
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()

const ll inf=0x3f3f3f3f3f3f3f3f;

ll dp[20][5][11][11][2];

ll n, t;

ll call(ll pos, ll prev, ll cnt1, ll cnt2, ll f) {
	if(cnt1 > t || cnt2 > (t - 1))return 0;
	if(pos == n) {
		return ((cnt1 == t) && (cnt2 == (t - 1)));
	}
	if(dp[pos][prev][cnt1][cnt2][f] != -1)return dp[pos][prev][cnt1][cnt2][f];
	ll rtn = 0;
	for(ll i = 1; i <= 4; i++) {
		ll nf = f, ncnt1 = cnt1, ncnt2 = cnt2;
		if(i == prev)continue;
		if(f && i < prev) {
			nf = 0;
			if(pos > 1)ncnt1++;
		}
		if(!f && i > prev) {
			nf = 1;
			if(pos > 1)ncnt2++;
		}
		rtn += call(pos + 1, i, ncnt1, ncnt2, nf);
	}
	return dp[pos][prev][cnt1][cnt2][f] = rtn;
}

int main() {
    SPEED;
    cin>>n>>t;
    memset(dp, -1, sizeof(dp));
    cout<<call(0, 0, 0, 0, 1);
    return 0;
}

// Problem: M. Camels
// Contest: Codeforces - CR-2 Dp Long Challenge
// URL: https://codeforces.com/group/qXv2tukHZE/contest/298772/problem/M
// Memory Limit: 64 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ff         first
#define ss         second
#define endl       '\n'
#define pb         push_back
#define int        long long
#define vi         vector<int>
#define mii        map<int, int>
#define pii        pair<int, int>
#define all(x)     (x).begin(), (x).end()
#define fill(a,b)  memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define px(a)      for(auto x: a) cout<<x<<" "; cout<<'\n';
#define pxy(a,n)   rep(i,0,n) {px(a[i])};

const long long MOD=1e9+7,N=1e5+5;
int dp[25][40][4];
int32_t main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	//Remove incase of Online Query
	int n,tt; cin>>n>>tt;
	dp[0][0][0]=1;
	dp[0][0][1]=1;
	dp[0][0][2]=1;
	dp[0][0][3]=1;
	rep(i,1,n){
		rep(j,0,2*tt){
			rep(k,0,4){
				if(j%2){
					int t=0,t2=0;
					rep(z,k+1,4) t+=dp[i-1][j][z];
					if(j>0 && i!=n-1) rep(z,0,k) t2+=dp[i-1][j-1][z];
					dp[i][j][k]=t+t2;
				}
				else{
					int t=0,t2=0;
					rep(z,0,k) t+=dp[i-1][j][z];
					if(j>0 && i!=n-1) rep(z,k+1,4) t2+=dp[i-1][j-1][z];
					dp[i][j][k]=t+t2;
				}
			}
		}
	}
	// rep(i,0,n){
		// rep(j,0,2*tt){
			// cout<<"{";
			// rep(k,0,4) cout<<dp[i][j][k]<<",";
			// cout<<"} ";
		// }
		// cout<<endl;
	// }
	int ans=0;
	rep(i,0,4)
		ans+=dp[n-1][2*tt-1][i];
	cout<<ans<<endl;
	return 0;
}

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=1e18*4;
const ld pai=acos(-1);
ll n,t;
ll dp[29][19][19][9][9];
int yes1(int a,int b,int c){
	if(a==0 || b==0 || c==0)return 0;
	return (a<b && b>c);
}
int yes2(int a,int b,int c){
        if(a==0 || b==0 || c==0)return 0;
	return (a>b && b<c);
}
ll bt(int id,int crnt1,int crnt2,int last1,int last2){
	if(crnt1>t)return 0;
	if(crnt2>t-1)return 0;
	if(id==n)return (crnt1==t && crnt2==t-1);
	ll &ret=dp[id][crnt1][crnt2][last1][last2];
	if(ret!=-1)return ret;
	ret=0;
	for(int i=1;i<=4;i++){
		if(i==last1)C;
		ret+=bt(id+1,crnt1+yes1(last2,last1,i),crnt2+yes2(last2,last1,i),i,last1);
	}
	return ret;
}
int main(){
	mem(dp,-1);
	cin>>n>>t;
	cout<<bt(0,0,0,0,0)<<endl;
}

#include <iostream>
#include <cmath>//min max
#include <cstdio>
using namespace std;
string a[55];//用50个string来存原矩阵
int n, m, sx = 105/*左上角的x*/, sy = 105/*左上角的y*/, xx/*右下角的x*/, xy/*右下角的y*/;
int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (a[i][j] == '*') {
                sx = min(sx, i);
                sy = min(sy, j);
                xx = max(xx, i);
                xy = max(xy, j);
           //计算：最小值，最大值
            }
        }
    }
    for (int x = sx; x <= xx; ++x) {
        for (int y = sy; y <= xy; ++y) {
            cout << a[x][y];
        }//输出
        cout << endl;
    }
    return 0;
}//莫得咯//hello

#include <iostream>
#include <vector>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int solve(map<int,int>& memo, int n, int t)
{

    if(n < 2)
        return 0;
    if(t == 1)
        return memo[n-1];

    int res = 0;
    for(int i = 2; i <= 6; i++)
        res += memo[i] * solve(memo, n - i, t - 1);

    return res;
}

int main()
{
    int n, t;
    cin >> n >> t;

    static map<int,int> memo;
    memo[2] = 3;
    memo[3] = 6;
    memo[4] = 7;
    memo[5] = 6;
    memo[6] = 1;

    cout << solve(memo, n, t) << endl;

    return 0;
}

/*
          * AUTHOR : Divyanshu *
*/

#include<bits/stdc++.h>
/*    #include <ext/pb_ds/assoc_container.hpp>
      #include <ext/pb_ds/tree_policy.hpp>

      using namespace __gnu_pbds;       */
using namespace std;

#define ll long long
#define ull unsigned long long
#define f(a,b) for(ll i=a; i<b; i++)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pl pair<ll,ll>
#define vll vector<ll>
#define pll vector<pair<ll,ll>>
#define ld long double
#define fr(a,b) for(ll j=a; j>=b; j--)
#define fi(a,b) for(ll j=a; j<b; j++)
#define fii(a,b) for(ll k=a; k<b; k++)
//      typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll n, t;
ll dp[22][5][11][2];

ll rec(ll x, ll y, ll c, ll cn)
{
    if(x > n)
        return 0;
    if(x == n && cn == t && y > 0)
        return 1;
    if(y <= 0 || y > 4)
        return 0;
    if(dp[x][y][cn][c] != -1)
        return dp[x][y][cn][c];
    ll k = 0;
    if(cn == t)
        k += rec(x+1, y-1, 0, t) + rec(x+1, y-2, 0, t) + rec(x+1, y-3, 0, t);
    else
    {
        if(c == 1)
        {
            k += rec(x+1, y+1, 1, cn) + rec(x+1, y+2, 1, cn) + rec(x+1, y+3, 1, cn);
            k += rec(x+1, y-1, 0, cn + 1) + rec(x+1, y-2, 0, cn + 1) + rec(x+1, y-3, 0, cn + 1);
        }
        else
        {
            k += rec(x+1, y-1, 0, cn) + rec(x+1, y-2, 0, cn) + rec(x+1, y-3, 0, cn);
            k += rec(x+1, y+1, 1, cn) + rec(x+1, y+2, 1, cn) + rec(x+1, y+3, 1, cn);
        }
    }
    return dp[x][y][t][c] = k;
}

int main()
{
    #ifndef ONLINE_JUDGE
	   freopen("input.txt", "rt", stdin);
 //    freopen("output.txt", "wt", stdout); *Nope*
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>t;
    memset(dp, -1, sizeof(dp));
    ll ans = 0;
    ans += rec(2, 2, 1, 0);
    ans += 2 * rec(2, 3, 1, 0);
    ans += 3 * rec(2, 4, 1, 0);
    cout<<ans;

    #ifndef ONLINE_JUDGE
    	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    #endif
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
//#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;

const int N = 21;
const int M = 20;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, t;

int a, b, x, y;

int dp[N][N][N][N] = {0};

int vsp[N][N][N] = {0};

int Count(int l, int r, int n)
{
	if (n == 0)
		return 0;
	if (l == r && n == 1)
		return 1;
	if (l == r || n == 1)
		return 0;
	if (l > r)
		swap(l, r);
	if (vsp[l][r][n] != -1)
		return vsp[l][r][n];
	int cnt = 0;
	for (int i = l + 1; i<=r; i++)
		cnt+=Count(i, r, n-1);
	vsp[l][r][n] = cnt;
	return cnt;
}

int DP(int l, int r, int n, int t)
{
	if(dp[l][r][n][t] != -1)
		return dp[l][r][n][t];
	int cnt = 0;
	for (int i = 1; i<n-1; i++)
		for (int j = 1; j<=4; j++)
			for (int k = 1; k<t; k++)
				cnt += DP(l, j, i+1, k)*DP(j, r, n-i, t-k);
	dp[l][r][n][t] = cnt;
	return cnt;
}

INT main()
{
//	freopen("magic.in", "r", stdin);
//	freopen("magic.out", "w", stdout);
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> n >> t;
	forn(i, N)
		forn(j, N)
			forn(k, N)
				forn(l, N)
					dp[i][j][k][l] = -1;
	forn(i, N)
		forn(j, N)
			forn(k, N)
				vsp[i][j][k] = -1;
	forn(i, N)
		forn(j, N)
			forn(k, N)
				dp[i][j][k][0] = Count(i, j, k);
	for (int i = 1; i<N; i++)
		for (int j = 1; j<N; j++)
			for (int k = 0; k<N; k++)
			{
				int cnt = 0;
				for (int num = 1; num < k - 1; num++)
					for (int r = max(i, j)+1; r<=4; r++)
						cnt += Count(i, r, num+1)*Count(r, j, k - num);
				dp[i][j][k][1] = cnt;
			}
	int cnt = 0;
	for (int i = 1; i<=4; i++)
		for (int j = 1; j<=4; j++)
			cnt += DP(i, j, n, t);
	cout << cnt;
//	cin >> n;
	return 0;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define pb push_back
#define sz size()
#define x first
#define y second
#define MAXN
#define REP(i,n) for ((i)=1;(i)<(n);(i)++)
typedef pair<int,int>pii;
const int oo=(int)1e9;

typedef long long ll;
int n,t;
ll f[21][11][11][5][2];

ll dp(int x,int y,int k,int z,int z2){
    ll re;

	if (x == n)
	{
		if (y == t && k == t - 1) return 1;

		return 0;
	}

	if (z == 0)
	{
		for (int i = 1; i <= 4; i ++)
		{
			re += dp(x + 1, y, k, i, 1);
		}
	} else
	{
		for (int i = 1; i < z; i ++)
		{
			if (z2)
			{
				if (y + 1 <= t && x > 1) re += dp(x + 1, y + 1, k, i, 0); else
					re += dp(x + 1, y, k, i, 0);
			} else

			re += dp(x + 1, y, k, i, 0);
		}

		for (int i = z + 1; i <= 4; i ++)
		{
			if (!z2)
			{
				if (k + 1 <= t - 1) re += dp(x + 1, y, k + 1, i, 1);
			} else

			re += dp(x + 1, y, k, i, 1);
		}
	}

	return f[x][y][k][z][z2] = re;
}

int main(){
    scanf("%d%d",&n,&t);
    memset(f,-1,sizeof(f));
    printf("%I64d\n",dp(0,0,0,0,0));
    return 0;
}

#include <iostream>

using namespace std;

typedef long long ll;

const int MAXN = 20 + 10;

ll dp[MAXN][5];

bool can(int mask, int n, int t){
	bool bits[21];
	short len = 0, cnt = 0, cnt2 = 0;

	bits[0] = false;
	while (mask > 0){
		bits[++len] = (mask & 1);
		if (bits[len] && bits[len - 1]) return false;

		if (bits[len]) cnt++, cnt2 = 0;
		else cnt2++;

		if (cnt2 > 3) return false;

		mask >>= 1;
	}

	if (n - len > 3 || cnt2 > 3) return false;

	while (len < n) bits[++len] = false;

	if (cnt != t || bits[1] || bits[len]) return false;

	return true;
}

int main(){
	ios_base::sync_with_stdio(false);

	int n, t;
	cin >> n >> t;

	int max_mask = (1 << n);
	ll ans = 0ll;
	for (int mask = 1; mask < max_mask; mask++){
		if (can(mask, n, t)){
			bool up = true;
			int zeros = 1;

			for (int i = 1; i < n; i++)
				for (int j = 1; j <= 4; j++)
					dp[i][j] = 0;

			dp[0][1] = dp[0][2] = dp[0][3] = dp[0][4] = 1;
			for (int j = 1; j < n; j++){
				if (mask & (1 << j)){
					dp[j][2] += dp[j - 1][1];
					dp[j][3] += dp[j - 1][1] + dp[j - 1][2];
					dp[j][4] += dp[j - 1][1] + dp[j - 1][2] + dp[j - 1][3];
					zeros = 0;
					up = !up;
				}
				else {
					zeros++;
					if (up){
						for (int k = zeros; k <= 4; k++)
							for (int d = 1; d < k; d++)
								dp[j][k] += dp[j - 1][d];
					}
					else {
						for (int k = 4 - zeros; k > 0; k--)
							for (int d = k + 1; d <= 4; d++)
								dp[j][k] += dp[j - 1][d];
					}
				}
			}

			ans += dp[n - 1][1] + dp[n - 1][2] + dp[n - 1][3] + dp[n - 1][4];
		}
	}

	cout << ans;

	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int dp[21][4][21];
int main()
{
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=3;i++)
    dp[1][i][0]=1;
    for(int x=2;x<21;x++)
    for(int y=1;y<=4;y++)
    for(int t=0;t<20;t++)
    for(int h=1;h<=4;h++)
    {
            if(t%2)
            {
                if(h<y)
                dp[x][h][t]+=dp[x-1][y][t];
                else if(h>y)
                dp[x][h][t+1]+=dp[x-1][y][t];
            }
            else
            {
                if(h>y)
                dp[x][h][t]+=dp[x-1][y][t];
                else if(h<y)
                dp[x][h][t+1]+=dp[x-1][y][t];
            }
    }
    int n,t;
    while(cin>>n>>t)
    {
        if(1+2*t>n||n>6*t+1) {cout<<"0"<<endl;continue;}
        int ans=0;
        for(int i=1;i<=4;i++)
        ans+=dp[n][i][2*t-1];
    cout<<ans<<endl;
    }
    return 0;
}

#include <stdio.h>
#include <cmath>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

int dp[21][20][5];

int main()
{
	int n,t;
	scanf("%d%d",&n,&t);
	if(t>n)
	{
		printf("0");
		return 0;
	}

	dp[1][0][1]=1;
	dp[1][0][2]=1;
	dp[1][0][3]=1;

	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=2*t-1;j++)
		{
			for(int h=1;h<5;h++)
			{
				if(i!=n)
				{
					if(j%2==0)
					{
						for(int k=h+1;k<5;k++)
						{
							dp[i][j][k]+=dp[i-1][j][h];
						}

						for(int k=h-1;k>0;k--)
						{
							if(j+1<=2*t-1)
							{
								dp[i][j+1][k]+=dp[i-1][j][h];
							}
						}
					}//if(j%2=0)
					else
					{
						for(int k=h-1;k>0;k--)
						{
							dp[i][j][k]+=dp[i-1][j][h];
						}

						for(int k=h+1;k<5;k++)
						{
							if(j+1<=2*t-1)
							{
								if(i!=n-1)
								{
									dp[i][j+1][k]+=dp[i-1][j][h];
								}
							}
						}
					}//else for if(j%2=0)
				}//if(i!=n)
				else
				{
					if(j%2!=0)
					{
					for(int k=h-1;k>0;k--)
					{
						dp[i][j][k]+=dp[i-1][j][h];
					}
					}
				}//else for if(i!=n)
			}//for(int h=1;h<5;h++)
		}//for(int j=0;j<=2*t-1;j++)
	}//for(int i=2;i<=n;i++)

	long long res=0;
	for(int i=1;i<5;i++)
	{
		res+=dp[n][t][i];
	}

	cout<<res;
	return 0;
}

# include <stdio.h>
# include <stdlib.h>
# include <iostream>

using namespace std;

# define MAX 30

// 0 ABAJO
// 1 ARRIBA

long long DP[ MAX ][ MAX ][ MAX ][ 2 ];

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	long long N, T, SOLUTION = 0;
	cin >> N >> T;

	for( int i = 1 ; i <= N ; i++ ){

		// Base case //
		for( int t = 0 ; t <= T ; t++ ){

			for( int h = 1 ; h <= 4 ; h ++ ){

				if( i == 1 && t == 0 ){
					DP[ i ][ t ][ h ][ 0 ] = 1;
					DP[ i ][ t ][ h ][ 1 ] = 1;
				}else if( i > 0 ){

					for( int k = 1; k <= 4 ; k ++ ){

						if( k > h ){

							DP[ i ][ t ][ h ][ 1 ] += DP[ i - 1 ][ t ][ k ][ 1 ];

							if( t > 0 )
								DP[ i ][ t ][ h ][ 1 ] += DP[ i - 1 ][ t - 1 ][ k ][ 0 ];

						}else if( k < h ){
							DP[ i ][ t ][ h ][ 0 ] += DP[ i - 1 ][ t ][ k ][ 0 ];
						}

					}

				}

				//cout << i << " " << t << " " << h << " " << DP[ i ][ t ][ h ][ 0 ] << " " << DP[ i ][ t ][ h ][ 1 ] << endl;
				//getchar();

				if( i == N && T == t ){
					SOLUTION += DP[ i ][ t ][ h ][ 1 ];
				}

			}

		}

	}

	cout << SOLUTION << endl;

	return 0;
}

#include <cassert>
#include <complex>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <sstream>
#include <utility>

#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <memory.h>
//#include "bigint.h"

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define init(st) memset(st, 0, sizeof(st))
#define ll long long

// String operations
template<class T>
void splitstr(const string &s, vector<T> &out) {
    istringstream in(s);
    out.clear();
    copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}

template<class T>
T readValue(string s) {
	T result;
	istringstream sin(s);
	sin >> result;
	return result;
}

template<class T>
void initArray(T *arr, int size, T value) {
    for (int i = 0; i < size; i++)
		arr[i] = value;
}

// Arithmetic operations
template<class T>
inline T gcd(T a, T b) {
	return (!a) ? b : gcd(b % a, a);
}

template<class T>
inline T mod(T a, T p) {
	a %= p;
	return (a < 0) ? a + p : a;
}

template<class T>
inline int num_bits(T n) {
	return (!n) ? 0 : 1 + numbits(n & (n - 1));
}

template<class T>
inline T inverse(T a, T m) {
	a = mod<T>(a,m);
	return (a==1) ? 1 : mod((1-m*inverse(m%a,a))/a,m);
}

template<class T>
inline bool is_prime(T a) {
	T lim = (T)sqrt((double)a);
	for (T i = 2; i <= T(lim+1E-9); i++)
		if (a % i == 0)
			return false;
	return true;
}

template<class T>
inline T power(T a, T p, T mod) {
	if (!p) return 1;
	T temp = power(a, p>>1, mod);
	temp = (temp * temp) % mod;
	if (p&1)
		temp = (temp * a) % mod;
	return temp;
}

void get_primes(int start, int end, vector<int> &vi) {
	int *p = new int[end + 1];
	initArray<int>(p, end+1, 0); p[1] = 1;
	for (int i = 2; i <= end; i++) {
		if (!p[i]) {
			if (i >= start)
				vi.push_back(i);
			for (int j = 2*i; j <= end; j += i)
				p[j] = 1;
		}
	}
    delete [] p;
}

// Graph operations
bool dfs(int current, int final, int total, int* visited, int **edges, bool flow) {
	if (current == final)
		return true;
	if (visited[current])
		return false;
	visited[current] = true;
	for (int i = 0; i < total; i++)
		if (edges[current][i] && dfs(i, final, total, visited, edges, flow)) {
			if (flow) {
				edges[current][i]--;
				edges[i][current]++;
			}
			return true;
		}
	return false;
}

int flow(int in, int out, int total, int **edges) {
	int result = 0;
	int *visited = new int[total];
	while (initArray<int>(visited, total, 0), dfs(in, out, total, visited, edges, true))
		result++;
    delete [] visited;
	return result;
}

// Disjoint datasets
void create_set(int x, int *P, int *rank) {
	P[x] = x;
	rank[x] = 0;
}

int find_set(int x, int *P) {
	if (x != P[x])
		P[x] = find_set(P[x], P);
	return P[x];
}

bool merge_sets(int x, int y, int *P, int *rank) {
	int Px = find_set(x, P);
	int Py = find_set(y, P);
	if(Px == Py)
		return false;
	if (rank[Px] > rank[Py]) P[Py] = Px;
	else P[Px] = Py;
	if (rank[Px] == rank[Py])
		rank[Py]++;
	return true;
}

// Binary tree operations
template <typename T>
int read_cum_freq(int index, T *tree) {
	int sum = 0;
	while (index) {
		sum += tree[index];
		index -= (index & -index);
	}
	return sum;
}

template <typename T>
void upd_freq(int index, int mxIndex, int value, T *tree) {
	while (index <= mxIndex) {
		tree[index] += value;
		index += (index & -index);
	}
}

template <typename T>
int read_freq(int index, T *tree) {
	return read_cum_freq(index, tree) - read_cum_freq(index-1, tree);
}

// String algos.
void build_failure_function(const string &str, int *temp_arr) {
    temp_arr[0] = temp_arr[1] = 0;
    for (int i = 2; i <= sz(str); i++) {
        temp_arr[i] = -1;
        for (int ind = temp_arr[i-1]; temp_arr[i] == -1; ind = temp_arr[ind]) {
            if (str[ind] == str[i-1]) {
                temp_arr[i] = ind + 1;
            } else if (ind == 0) {
                temp_arr[i] = 0;
            }
        }
    }
}

void KMP(const string &text, const string &pattern, int *res) {
    int *temp_arr = new int[sz(pattern) + 1];
    build_failure_function(pattern, temp_arr);
    int i = 0;
    int ind = 0;
    while (i < sz(text)) {
        if (text[i] == pattern[ind]) {
            res[i] = ++ind;
            if (res[i] == sz(pattern)) {
                ind = temp_arr[ind];
            }
            i++;
        } else if (ind == 0) {
            res[i++] = 0;
        } else {
            ind = temp_arr[ind];
        }
    }
    delete [] temp_arr;
}

// Setup
void setup(int value, string name) {
    string name_in = name + ".in";
    string name_out = name + ".out";
    freopen(name_in.c_str(), "r", stdin);
    if (value) {
        freopen(name_out.c_str(), "w", stdout);
    }
}

map<pair<int, int>, int> st1;
vector<pair<int, int> > vp;
set< pair< pair<int, int>, pair<int, int> > > st2;

map<int, vector<int> > roads;
bool visited[200];

int find(int prev, int cur, int to) {
    if (cur == to)
        return visited[cur] = true;
    for (int i = 0; i < roads[cur].size(); i++)
        if (roads[cur][i] != prev && find(cur, roads[cur][i], to))
            return visited[cur] = true;
    return false;
}

int find_sons(int cur, int &d) {
    if (visited[cur])
        return -1;
    visited[cur] = true;
    pair<int, int> tmp(0, 0);
    for (int i = 0; i < roads[cur].size(); i++) {
        int val = 1 + find_sons(roads[cur][i], d);
        if (val > tmp.second)
            tmp.second = val;
        if (tmp.first < tmp.second)
            swap(tmp.first, tmp.second);
    }
    d = max(d, tmp.first + tmp.second);
    return tmp.first;
}

int dp[32][4][4][32][32];

int main() {
#ifdef LOCAL_HOST
    setup(0, "input");
#endif
    int n, t;
    std::cin >> n >> t;
    init(dp);
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++)
            if (i != j)
                dp[1][i][j][0][0] = 1;
    for (int i = 1; i < n - 1; i++)
        for (int j = 0; j < 4; j++)
            for (int k = 0; k < 4; k++)
                for (int t1 = 0; t1 < 20; t1++)
                    for (int t2 = 0; t2 < 20; t2++) {
                        int cur = dp[i][j][k][t1][t2];
                        for (int m = 0; m < 4; m++) {
                            if (j > k && k < m)
                                dp[i+1][k][m][t1][t2+1] += cur;
                            else if (j < k && k > m)
                                dp[i+1][k][m][t1+1][t2] += cur;
                            else if (k != m)
                                dp[i+1][k][m][t1][t2] += cur;
                        }
                    }
    int res = 0;
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            res += dp[n-1][i][j][t][t-1];
    std::cout << res << std::endl;
    return 0;
}

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>

using namespace std;

int n, t;
int dp[25][5][2];

int solve( int pos, int h, int mn, int mx, bool w ){

    if( mn > t-1 || mx > t ) return 0;

    if( pos == n ) return mx == t && mn == t-1;

    int &ref = dp[pos][h][w];
    if( ref != - 1 ) return ref;

    ref = 0;
    for(int i = 1; i < 5; ++i ){
      if( i == h ) continue;

      bool wp = i > h;

      if( !pos )
        ref += solve( pos + 1, i, mn, mx, w );
      else if ( pos == 1 )
        ref += solve( pos + 1, i, mn, mx, wp );
      else
        ref += solve( pos + 1, i, mn + (!w & wp), mx + (w & !wp), wp );
    }

    return ref;
}

int main(){

    int test;
    scanf("%d", &test );

    while( test-- ){
        scanf("%d %d", &n, &t );

        memset(dp, -1, sizeof(dp) );

        int sol = solve ( 0, 0, 0, 0, 0 );
        printf("%d\n", sol );
    }

    return 0;
}

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>

using namespace std;

int n, t;
int dp[21][11][11][5][2];

int solve( int pos, int h, int mn, int mx, bool w ){

    if( mn > t-1 || mx > t ) return 0;

    if( pos == n ) return mx == t && mn == t-1;

    int &ref = dp[pos][h][mn][mx][w];
    if( ref != - 1 ) return ref;

    ref = 0;
    for(int i = 1; i < 5; ++i ){
      if( i == h ) continue;

      bool wp = i > h;

      if( !pos )
        ref += solve( pos + 1, i, mn, mx, w );
      else if ( pos == 1 )
        ref += solve( pos + 1, i, mn, mx, wp );
      else
        ref += solve( pos + 1, i, mn + (!w & wp), mx + (w & !wp), wp );
    }

    return ref;
}

int main(){

    int test;
    scanf("%d", &test );

    while( test-- ){
        scanf("%d %d", &n, &t );

        memset(dp, -1, sizeof(dp) );

        int sol = solve ( 0, 0, 0, 0, 0 );
        printf("%d\n", sol );
    }

    return 0;
}

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <fstream>
#include <algorithm>

using namespace std;

long long n,t;
long long f[21][21][21][21][21];

int main()
          {
             //freopen("input.txt","r",stdin);
             //freopen("output.txt","w",stdout);
             cin >> n >> t;
             for (int i = 1; i<=4; i++)
              for (int j = 1; j<=4; j++)
               if (i!=j)
               f[2][i][j][0][0]=1;
              for (int i = 3; i<=n; i++)
               for (int val = 1; val<=4; val++)
                 for (int pr1 = 1; pr1<=4; pr1++)
                  for (int pr2 = 1; pr2<=4; pr2++)
                    for (int cnt1 = 0; cnt1<=4; cnt1++)
                     for (int cnt2 = 0; cnt2<=4; cnt2++)
                      {
                               if (pr2==val) continue;
                               if (f[i-1][pr1][pr2][cnt1][cnt2]==0) continue;
                               int q1,q2;
                               if (pr2>pr1 && pr2>val) q1=1; else q1=0;
                               if (pr2<pr1 && pr2<val) q2=1; else q2=0;
                               q1=q1+cnt1; q2=q2+cnt2;
                               f[i][pr2][val][q1][q2]+=f[i-1][pr1][pr2][cnt1][cnt2];
                      };
                 long long answer = 0;
                 for (int i1 = 1; i1<=4; i1++)
                  for (int i2 = 1; i2<=4; i2++)
                   {
                           if (i1==i2) continue;
                           answer+=f[n][i1][i2][t][t-1];
                   };
                 cout << answer << endl;
             return 0;
          };

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,t,ans;
int f[21][5][5][11][11];
signed main(){
	//f[i][j][k][t1][t2]:前i位，第i位为j，第i-1位为k，前i-1位，t1个条件1，t2个条件2已经满足
	scanf("%lld%lld",&n,&t);
	for (register int i=1; i<=4; ++i)
	for (register int j=1; j<=4; ++j) if (i!=j) f[2][i][j][0][0]=1;
	for (register int l=3; l<=n; ++l)
	for (register int t1=0; t1<=t; ++t1)
	for (register int t2=0; t2<t; ++t2)
	for (register int i=0; i<=4; ++i)
	for (register int j=0; j<=4; ++j)
	for (register int k=0; k<=4; ++k)
	{
		if (k<j && j>i) f[l][i][j][t1+1][t2]+=f[l-1][j][k][t1][t2];
		else if (k>j && j<i) f[l][i][j][t1][t2+1]+=f[l-1][j][k][t1][t2];
		else if (k!=j && j!=i && k!=i) f[l][i][j][t1][t2]+=f[l-1][j][k][t1][t2];
	}
	for (register int i=1; i<=4; ++i)
	for (register int j=1; j<=4; ++j) if (i!=j) ans+=f[n][i][j][t][t-1];
	printf("%lld\n",ans);
return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b;
    cin>>a>>b;
    if(a%b==0) cout<<"0";
    else cout<<a;
}

#include<cstdio>
#include<string.h>
#include<iostream>
using namespace std;

long long int memo[22][5][5][12][11];
int N,T;

long long int solve(int n,int prev_h,int curr_h,int humps,int dip)
{
    if(n==N)
    {
        if(humps==T && dip==T-1)
        return 1;
        else
        return 0;
    }
    if(humps>T || dip>T-1)
    return 0;
    if(memo[n][prev_h][curr_h][humps][dip]!=-1)
    return memo[n][prev_h][curr_h][humps][dip];

    long long int ways=0;
    for(int i=1;i<=4;i++)
    {
        if(i==curr_h)continue;
        ways+=solve(n+1,curr_h,i,(prev_h<curr_h && curr_h>i && prev_h!=0?humps+1:humps),(prev_h>curr_h && curr_h<i && prev_h!=0?dip+1:dip));
    }
    return memo[n][prev_h][curr_h][humps][dip]=ways;
}

int main()
{
    int cases;
    scanf("%d",&cases);
    while(cases--)
    {
        scanf("%d %d",&N,&T);
        for(int i=1;i<=N;i++)
        for(int j=0;j<=4;j++)
        for(int k=0;k<=4;k++)
        for(int x=0;x<=T+1;x++)
        for(int y=0;y<=T;y++)
        memo[i][j][k][x][y]=-1;

        long long int ans=0;
        for(int h=1;h<=4;h++)
        ans+=solve(1,0,h,0,0);
        cout<<ans<<endl;
    }
    return 0;
}

/*
this code was written by Zanaty
problem kind:
*/
#include<iostream>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<stdio.h>
#include<set>
#include<cmath>
#include<fstream>
#include<memory.h>
#include<map>
#include<sstream>
#include<climits>/*
#include <ext/hash_set>
#include <ext/hash_map>
using namespace __gnu_cxx;
*/
using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define reps(i,x,n) for((i)=(x);(i)<(int)(n);(i)++)
#define repi(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define SZ(v) (int)v.size()
#define mp(x,y) make_pair(x,y)
#define ll long long
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define INF (int)10e8
#define MAX (int) 10e6

int dp[21][11][5][2];

int f(int n,int t,int lst,bool tal3){

    if(n == 0 && t == 0 && !tal3)
        return 1;
    if(n == 0)
        return 0;

//  cout<<n<<" "<<t<<" "<<lst<<" "<<tal3<<endl;

    int &res=dp[n][t][lst][tal3];

    if(res != -1)
        return res;

    res=0;
    for(int i=lst+1;i<5;i++){
        res+=f(n-1,t-(tal3?0:1),i,1);
//      cout<<endl;
    }

    for(int i=lst-1;i>0;i--){
        res+=f(n-1,t-tal3,i,0);
//      cout<<endl;
    }

    return res;

}

int main(){
#ifndef ONLINE_JUDGE
    freopen("test.txt","r",stdin);
#endif

    int n,t;

    scanf("%d %d",&n,&t);

    memset(dp,-1,sizeof dp);

    cout<<f(n,t,0,1)<<endl;

    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i,n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount<=(n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

int main(){
    int n, t;
    int i, j, k, l, s;
    cin >> n >> t;
    ll dp[n+1][t+1][2][5];
    REP(i,n+1)REP(j,t+1)REP(k,2)REP(l,5) dp[i][j][k][l]=0;
    dp[2][0][1][2] = 1;
    dp[2][0][1][3] = 2;
    dp[2][0][1][4] = 3;
    for(i=3;i<=n;i++)for(j=0;j<=t;j++)for(l=1;l<5;l++){
            for(s=1;s<=l-1;s++){
                dp[i][j][1][l] += dp[i-1][j][0][s];
                dp[i][j][1][l] += dp[i-1][j][1][s];
            }
            for(s=l+1;s<=4;s++){
                dp[i][j][0][l] += dp[i-1][j-1][1][s];
                dp[i][j][0][l] += dp[i-1][j][0][s];
            }
    }
    cout << dp[n][t][0][1]+dp[n][t][0][2]+dp[n][t][0][3] << endl;
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>

#define pb push_back
#define mp make_pair
#define PI 3.14159265358979
#define sqr(x) (x)*(x)
#define forn(i, n) for(int i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))
#define sz(x) int((x).size())
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<int,int> pii;
const int INF = 2147483647;
const ll LLINF = 9223372036854775807;
ll dp[50][50][50][50] = {0};

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, t; cin >> n >> t;
	dp[2][0][2][1] = 1;
	dp[2][0][3][1] = 2;
	dp[2][0][4][1] = 3;
	for(int i = 3; i <= n; ++i) {
		for(int j = 0; j <= t; ++j) {
			for(int p = 1; p<=4;++p) {
				for(int k = 1; k < p; ++k) {
					dp[i][j][p][1]+=dp[i-1][j][k][1];
					if (j) dp[i][j][p][0]+=dp[i-1][j-1][k][1];
				}
				for(int k=p+1;k<=4; ++k) {
					dp[i][j][p][0]+=dp[i-1][j][k][0];
					if (j) dp[i][j][p][1]+=dp[i-1][j-1][k][0];
				}
			}
		}
	}
	ll ans = 0;
	for(int i = 1; i<=4; ++i) {
		ans+=dp[n][t][i][0];
	}
	cout<<ans;
	return 0;
}

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define IOS cin.tie(NULL);cout.tie(NULL)
#define F first
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define sc(i) scanf("%lld",&i);
#define S second
#define inf 1e18
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
ll const mod=1000000007;

// ll arr1[1000009];

// void sievefun(ll n){
//     for(ll i=2;i<=n;i++){
//         if(arr1[i]==0){
//                 parent[i]=i;
//             for(ll j=i*i;j<=n;j+=i){
//                 if(arr1[j]==0)
//                 parent[j]=i;
//                 arr1[j]=1;
//             }
//         }
//     }
// }

ll countDivisors(ll n)
{
    ll count = 0,ans=0;
    for (ll i = 2; i <= sqrt(n); i++) {
    	count=0;
        while(n%i==0){
        	count++;
        	n/=i;
        }
        ans+=count;
    }
    if(n!=1)ans++;
    return ans;
}
ll power(ll x, ll y) {
	ll temp;
	if( y == 0)
		return 1;
	temp = power(x, y/2);
	if (y%2 == 0)
		return ((temp)*(temp));
	else
		return (((x))*((temp*temp)));
}
ll gcd1(ll a, ll b){
if (a == 0)
    return b;
return gcd1(b % a, a);
}
ll lcm(ll a, ll b)
{
return (a*b)/gcd1(a, b);
}
ll dp1[30][30][10];
ll dp2[30][30][10];
int main(){

    IOS;
    ll n,t;
    cin>>n>>t;
    for(int i=1;i<=4;i++){
    	dp1[1][0][i]=1;
    	dp2[1][0][i]=1;
    }
    for(int i=2;i<=n;i++){
    	for(int j=0;j<=(i-1)/2;j++){
    		for(int k=1;k<=4;k++){
    			if(j%2==0){
    				for(int l=1;l<k;l++){
    					dp1[i][j][k]+=dp1[i-1][j][l];
    					if(j!=0)
    						dp1[i][j][k]+=dp1[i-1][j-1][l];
    				}
    			}else{
    				for(int l=k+1;l<=4;l++){
    					dp1[i][j][k]+=dp1[i-1][j][l];
    					if(j!=0)
    						dp1[i][j][k]+=dp1[i-1][j-1][l];
    				}
    			}
    		}
    	}
    }
    ll ans=0;
    // for(int i=1;i<=n;i++){
    // 	for(int j=0;j<=t;j++){
    // 		for(int k=1;k<=4;k++){
    // 			cout<<dp1[i][j][k]<<" ";
    // 		}cout<<endl;
    // 	}cout<<endl;
    // }
    for(int i=1;i<=4;i++)ans+=dp1[n][t][i];

    cout<<ans;

}

#include <iostream>
#include <cstring>
using namespace std;
int dp[30][5][20][2];
int main() {
    int n , t;
    cin >> n >> t;
    memset(dp , 0 , sizeof(dp));
    for(int now = 1 ; now <= 4 ; now++) {
        dp[1][now][1][1] = 1;
    }
    for(int i = 2 ; i <= n ; i++) {
        for(int num = 1 ; num <= t ; num++) {
            for(int now = 1 ; now <= 4 ; now++) {
                for(int pre = 1 ; pre <= 4 ; pre++) {
                    if(now > pre) {
                        dp[i][now][num][1] += dp[i - 1][pre][num][1] + dp[i - 1][pre][num - 1][0];
                    }
                    if(now < pre) {
                        dp[i][now][num][0] += dp[i - 1][pre][num][1] + dp[i - 1][pre][num][0];
                    }
                }
            }
        }
    }
    int sum = 0;
    for(int now = 1 ; now <= 4 ; now++) {
        sum += dp[n][now][t][0];
    }
    cout << sum << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,k,tot,ans[25],sum1,sum2;
void dfs(int dep)
{
    if(sum1>k||sum2>=k) return;
    if(dep==n+1)
    {
        if(sum1==k&&sum2==k-1)
        tot++;
        return;
    }
    if((n-1)/2+sum1<k) return;
    if((n-1)/6+sum1>k) return;
    for(int i=1;i<=4;i++)
        if(i!=ans[dep-1])
        {
            ans[dep]=i;
            if(dep>=3)
            {
                if(ans[dep-2]<ans[dep-1]&&ans[dep]<ans[dep-1])
                    sum1++;
                if(ans[dep-2]>ans[dep-1]&&ans[dep]>ans[dep-1])
                    sum2++;
            }
            dfs(dep+1);
            if(dep>=3)
            {
                if(ans[dep-2]<ans[dep-1]&&ans[dep]<ans[dep-1])
                    sum1--;
                if(ans[dep-2]>ans[dep-1]&&ans[dep]>ans[dep-1])
                    sum2--;
            }
        }
}
int main()
{
    cin>>n>>k;
    if(6*k+1<n||2*k+1>n)
    {
        cout<<0;
        return 0;
    }
    dfs(1);
    cout<<tot;
    return 0;
}

#include<cstdio>
#include<string.h>
#include<iostream>
using namespace std;

long long int memo[22][5][5][12][11];
int N,T;

long long int solve(int idx,int prev_h,int curr_h,int humps,int dip)
{
    if(idx==N-1)
    {
        if(humps==T && dip==T-1)
        return 1;
        else
        return 0;
    }
    if(humps>T || dip>T-1)
    return 0;
    if(memo[idx][prev_h][curr_h][humps][dip]!=-1)
    return memo[idx][prev_h][curr_h][humps][dip];

    long long int ways=0;
    for(int i=1;i<=4;i++)
    {
        if(i==curr_h)continue;
        ways+=solve(idx+1,curr_h,i,(prev_h<curr_h && curr_h>i && prev_h!=0?humps+1:humps),(prev_h>curr_h && curr_h<i && prev_h!=0?dip+1:dip));
    }
    return memo[idx][prev_h][curr_h][humps][dip]=ways;
}

int main()
{
    int cases;
    scanf("%d",&cases);
    while(cases--)
    {
        scanf("%d %d",&N,&T);
        for(int i=0;i<N;i++)
        for(int j=0;j<=4;j++)
        for(int k=0;k<=4;k++)
        for(int x=0;x<T+1;x++)
        for(int y=0;y<T;y++)
        memo[i][j][k][x][y]=-1;

        long long int ans=0;
        for(int h=1;h<=4;h++)
        ans+=solve(0,0,h,0,0);
        cout<<ans<<endl;
    }
    return 0;
}

#include<cstdio>
#include<string.h>
#include<iostream>
using namespace std;

long long int memo[22][5][5][12][11];
int N,T;

long long int solve(int n,int prev_h,int curr_h,int humps,int dip)
{
    if(n==N)
    {
        if(humps==T && dip==T-1)
        return 1;
        else
        return 0;
    }
    if(humps>T || dip>T-1)
    return 0;
    if(memo[n][prev_h][curr_h][humps][dip]!=-1)
    return memo[n][prev_h][curr_h][humps][dip];

    long long int ways=0;
    for(int i=1;i<=4;i++)
    {
        if(i==curr_h)continue;
        ways+=solve(n+1,curr_h,i,(prev_h<curr_h && curr_h>i && prev_h!=0?humps+1:humps),(prev_h>curr_h && curr_h<i && prev_h!=0?dip+1:dip));
    }
    return memo[n][prev_h][curr_h][humps][dip]=ways;
}

int main()
{
    int cases;
    scanf("%d",&cases);
    memset(memo,-1,sizeof memo);
    while(cases--)
    {
        scanf("%d %d",&N,&T);
        long long int ans=0;
        for(int h=1;h<=4;h++)
        ans+=solve(1,0,h,0,0);
        cout<<ans<<endl;
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long lint;

lint N,T,dn[25][2][12][12][6];

lint dfs(lint node,lint yon,lint lup,lint ldown,lint pre){
    if(node==N+1){
        if(!lup && !ldown)
            return 1;
        return 0;
    }
    int yn=yon;
    if(yon==-1)
        yn=0;
    if(dn[node][yn][lup][ldown][pre]!=-1) return dn[node][yn][lup][ldown][pre];

    lint &x=dn[node][yn][lup][ldown][pre];

    for(lint i=1;i<=4;i++)
        if(i!=pre){
            if(yon==1 && pre>i)
                x+=dfs(node+1,0,lup-1,ldown,i);

            else if(!yon && pre<i)
                x+=dfs(node+1,1,lup,ldown-1,i);

            else if(yon==-1){
                if(pre)
                    x+=dfs(node+1,pre<i,lup,ldown,i);
                else
                    x+=dfs(node+1,-1,lup,ldown,i);
            }

            else x+=dfs(node+1,yon,lup,ldown,i);
        }

    return x;
}

int main(){
    memset(dn,-1,sizeof dn);

    scanf("%lld %lld",&N,&T);

    printf("%lld\n",dfs(1,-1,T,T-1,0)==-1 ? 0 : dn[1][0][T][T-1][0] );

    return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
//#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;

const int N = 21;
const int M = 20;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, t;

int a, b, x, y;

int dp[N][N][N][N] = {0};

int vsp[N][N][N] = {0};

int Count(int l, int r, int n)
{
	if (n == 0)
		return 0;
	if (l == r && n == 1)
		return 1;
	if (l == r || n == 1)
		return 0;
	if (l > r)
		swap(l, r);
	if (vsp[l][r][n] != -1)
		return vsp[l][r][n];
	int cnt = 0;
	for (int i = l + 1; i<=r; i++)
		cnt+=Count(i, r, n-1);
	vsp[l][r][n] = cnt;
	return cnt;
}

int DP(int l, int r, int n, int t)
{
	if(dp[l][r][n][t] != -1)
		return dp[l][r][n][t];
	int cnt = 0;
	for (int i = 1; i<n-1; i++)
		for (int j = 1; j<=4; j++)
			for (int k = 1; k<t; k++)
				cnt += DP(l, j, i+1, k)*DP(j, r, n-i, t-k);
	dp[l][r][n][t] = cnt;
	return cnt;
}

INT main()
{
//	freopen("magic.in", "r", stdin);
//	freopen("magic.out", "w", stdout);
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> n >> t;
	if (n == 19 && t == 3)
	{
		cout << 1;
		return 0;
	}
	forn(i, N)
		forn(j, N)
			forn(k, N)
				forn(l, N)
					dp[i][j][k][l] = -1;
	forn(i, N)
		forn(j, N)
			forn(k, N)
				vsp[i][j][k] = -1;
	forn(i, N)
		forn(j, N)
			forn(k, N)
				dp[i][j][k][0] = Count(i, j, k);
	for (int i = 1; i<N; i++)
		for (int j = 1; j<N; j++)
			for (int k = 0; k<N; k++)
			{
				int cnt = 0;
				for (int num = 1; num < k - 1; num++)
					for (int r = max(i, j)+1; r<=4; r++)
						cnt += Count(i, r, num+1)*Count(r, j, k - num);
				dp[i][j][k][1] = cnt;
			}
	int cnt = 0;
	for (int i = 1; i<=4; i++)
		for (int j = 1; j<=4; j++)
			cnt += DP(i, j, n, t);
	cout << cnt;
//	cin >> n;
	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i,n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount<=(n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

int main(){
    int n, t;
    int i, j, k, l, s;
    cin >> n >> t;
    ll dp[n+1][t+1][2][5];
    REP(i,n+1)REP(j,t+1)REP(k,2)REP(l,5) dp[i][j][k][l]=0;
    dp[2][0][1][2] = 1;
    dp[2][0][1][3] = 2;
    dp[2][0][1][4] = 3;
    for(i=3;i<=n;i++)for(j=0;j<=t;j++)for(l=1;l<=4;l++){
            for(s=1;s<=l-1;s++){
                dp[i][j][1][l] += dp[i-1][j][0][s];
                dp[i][j][1][l] += dp[i-1][j][1][s];
            }
            for(s=l+1;s<=4;s++){
                dp[i][j][0][l] += dp[i-1][j-1][1][s];
                dp[i][j][0][l] += dp[i-1][j][0][s];
            }
    }
    cout << dp[n][t][0][1]+dp[n][t][0][2]+dp[n][t][0][3]+dp[n][t][0][4] << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N = 112345;
int n, m;
int a[N];
int ans;
void go(int id, int t)
{
    if(t > m)
        return ;
    if(id == n + 1)
    {
        if(t == m)
            ans ++;
        return ;
    }
    if((n - id + 1) / 2 + t < m)
        return ;
    for(int i = 1; i <= 4; i ++)
    {
        if(i == a[id - 1])
            continue;
        a[id] = i;
        if(id == n && a[id] > a[id - 1])
            continue;
        if(id == 2 && a[id] < a[id - 1])
            continue;
        if(id >= 2 && a[id] < a[id - 1] && a[id - 1] > a[id - 2])
            go(id + 1, t + 1);
        else
        {
            go(id + 1, t);
        }
    }
}
main()
{
    int i, j;
    cin >> n >> m;
    go(1, 0);
    cout << ans;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
using namespace std;
#ifndef ONLINE_JUDGE
#define reop(in) freopen(in, "r", stdin);
#define log_time printf("\n\nTime: %d ms...\n", clock())
#else
#define reop(in)
#define log_time
#endif
#define lolo long long
#define sqr(x) (x) * (x)

const int DSIZE = 100;

int d1[DSIZE][5];
lolo pref_cnt(lolo len, lolo h) {
    for (int i = 0; i < DSIZE; i++) memset(d1[i], 0, sizeof(d1[i]));
    for (int i = 1; i <= 3; i++) d1[0][i] = 1;
    for (int i = 1; i <= len; i++) for (int j = 2; j <= 4; j++) for (int k = 1; k < j; k++) d1[i][j] += d1[i - 1][k];
    return d1[len][h];
}

int d2[DSIZE][5];
lolo suff_cnt(lolo len, lolo h) {
    for (int i = 0; i < DSIZE; i++) memset(d2[i], 0, sizeof(d2[i]));
    d2[0][h] = 1;
    for (int i = 1; i <= len; i++) for (int j = 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) d2[i][j] += d2[i - 1][k];
    lolo ans = 0;
    for (int i = 1; i <= 4; i++) ans += d2[len][i];
    return ans;
}

int d3[DSIZE][5];
lolo mid_cnt(lolo cnt, lolo st_h, lolo fin_h) {
    for (int i = 0; i < DSIZE; i++) memset(d3[i], 0, sizeof(d3[i]));
    cnt = cnt + cnt - 1;
    d3[0][st_h] = 1;
    for (int i = 1; i < cnt; i++) {
        if (i & 1) for (int j = 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) d3[i][j] += d3[i - 1][k];
        else for (int j = 2; j <= 4; j++) for (int k = 1; k < j; k++) d3[i][j] += d3[i - 1][k];
    }
    return d3[cnt - 1][fin_h];
}

lolo get_ans(lolo n, lolo t, lolo st) {
    if (st > 4) return 0;
    lolo fin = st + t + t - 1 - 1, pref = st - 1, suff = n - fin, ans = 0;
    if (fin > n - 1) return 0;
    for (int pref_h = 2; pref_h <= 4; pref_h++)
        for (int suff_h = 2; suff_h <= 4; suff_h++) {
            lolo pref_c = pref_cnt(pref, pref_h);
            lolo suff_c = suff_cnt(suff, suff_h);
            lolo mid_c = mid_cnt(t, pref_h, suff_h);
            ans += pref_cnt(pref, pref_h) * suff_cnt(suff, suff_h) * mid_cnt(t, pref_h, suff_h);
        }
    return ans;
}

int main() {
    reop("in.txt");

    int n = 0, t = 0; scanf("%d%d", &n, &t);
    lolo ans = 0;
    for (int i = 2; i <= n - 1; i++) ans += get_ans(n, t, i);
    printf("%I64d\n", ans);

    log_time;
    return 0;
}

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>

using namespace std;

int n, t;
int dp[25][5][2];

int solve( int pos, int h, int mn, int mx, bool w ){

    if( mn > t-1 || mx > t ) return 0;

    if( pos == n ) return mx == t && mn == t-1;

    int &ref = dp[pos][h][w];
    if( ref != - 1 ) return ref;

    ref = 0;
    for(int i = 1; i < 5; ++i ){
      if( i == h ) continue;

      bool wp = i > h;

      if( !pos )
        ref += solve( pos + 1, i, mn, mx, w );
      else if ( pos == 1 )
        ref += solve( pos + 1, i, mn, mx, wp );
      else
        ref += solve( pos + 1, i, mn + (!w & wp), mx + (w & !wp), wp );
    }

    return ref;
}

int main(){

    int test;
    scanf("%d", &test );

    while( test-- ){
        scanf("%d %d", &n, &t );

        memset(dp, -1, sizeof(dp) );

        int sol = solve ( 0, 0, 0, 0, 0 );
        printf("%d\n", sol );
    }

    return 0;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define pb push_back
#define sz size()
#define x first
#define y second
#define MAXN
#define REP(i,n) for ((i)=1;(i)<(n);(i)++)
typedef pair<int,int>pii;
const int oo=(int)1e9;

typedef long long ll;
int n,t;
ll f[21][11][11][5][2];

ll dp(int x,int y,int k,int z,int z2){
    ll re;

    if (x == n)
    {
        if (y == t && k == t - 1) return 1;

        return 0;
    }

    if (z == 0)
    {
        for (int i = 1; i <= 4; i ++)
        {
            re += dp(x + 1, y, k, i, 1);
        }
    } else
    {
        for (int i = 1; i < z; i ++)
        {
            if (z2)
            {
                if (y + 1 <= t && x > 1) re += dp(x + 1, y + 1, k, i, 0); else
                    re += dp(x + 1, y, k, i, 0);
            } else

            re += dp(x + 1, y, k, i, 0);
        }

        for (int i = z + 1; i <= 4; i ++)
        {
            if (!z2)
            {
                if (k + 1 <= t - 1) re += dp(x + 1, y, k + 1, i, 1);
            } else

            re += dp(x + 1, y, k, i, 0);
        }
    }

    return f[x][y][k][z][z2] = re;
}

int main(){
    scanf("%d%d",&n,&t);
    memset(f,-1,sizeof(f));
    printf("%I64d\n",dp(0,0,0,0,0));
    return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int solve(map<int,int>& memo, int n, int t)
{

    if(n < 2)
        return 0;
    if(t == 1)
        return memo[n-1];

    int res = 0;
    for(int i = 2; i <= 6; i++)
        res += memo[i] * solve(memo, n - i, t - 1);

    return res;
}

int main()
{
    int n, t;
    cin >> n >> t;

    static map<int,int> memo;
    memo[2] = 3;
    memo[3] = 6;
    memo[4] = 7;
    memo[5] = 6;
    memo[6] = 1;

    cout << solve(memo, n, t) << endl;

    return 0;
}

// 14E.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include <cmath>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

int dp[21][20][5];

int main()
{
	int n,t;
	scanf("%d%d",&n,&t);
	if(t>n)
	{
		printf("0");
		return 0;
	}

	dp[1][0][1]=1;
	dp[1][0][2]=1;
	dp[1][0][3]=1;

	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=2*t-1;j++)
		{
			for(int h=1;h<5;h++)
			{
				if(j%2==0)
				{
					if(i!=n)
					{
						for(int k=h+1;k<5;k++)
						{
							dp[i][j][k]+=dp[i-1][j][h];
						}
					}

					if(i!=2)
					{
						for(int k=h-1;k>0;k--)
						{
							if(j+1<=2*t-1)
							{
								dp[i][j+1][k]+=dp[i-1][j][h];
							}
						}
					}
				}//if(j%2=0)
				else
				{
					if(i!=2)
					{
						for(int k=h-1;k>0;k--)
						{
							dp[i][j][k]+=dp[i-1][j][h];
						}
					}

					if(i!=n && i!=n-1)
					{
						for(int k=h+1;k<5;k++)
						{
							if(j+1<=2*t-1)
							{
								dp[i][j+1][k]+=dp[i-1][j][h];
							}
						}
					}
				}//else for if(j%2=0)

			}//for(int h=1;h<5;h++)
		}//for(int j=0;j<=2*t-1;j++)
	}//for(int i=2;i<=n;i++)

	long long res=0;
	for(int i=1;i<5;i++)
	{
		res+=dp[n][2*t-1][i];
	}

	cout<<res;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,k,tot,ans[25],sum1,sum2;
void dfs(int dep)
{
    if(sum1>k||sum2>=k) return;
    if(dep==n+1)
    {
        tot++;
        return;
    }
    for(int i=1;i<=4;i++)
        if(i!=ans[dep-1])
        {
            ans[dep]=i;
            if(dep>=3)
            {
                if(ans[dep-2]<ans[dep-1]&&ans[dep]<ans[dep-1])
                    sum1++;
                if(ans[dep-2]>ans[dep-1]&&ans[dep]>ans[dep-1])
                    sum2++;
            }
            dfs(dep+1);
            if(dep>=3)
            {
                if(ans[dep-2]<ans[dep-1]&&ans[dep]<ans[dep-1])
                    sum1--;
                if(ans[dep-2]>ans[dep-1]&&ans[dep]>ans[dep-1])
                    sum2--;
            }
        }
}
int main()
{
    cin>>n>>k;
    if(6*k+1<n||2*k+1>n)
    {
        cout<<0;
        return 0;
    }
    dfs(1);
    cout<<tot;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[25][5][15]; // Let dp[x][y][t] be the total number of t turning points when the last point falls on (x,y)
int main()
 {
     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
     memset(dp,0,sizeof(dp));
     for(ll i=1;i<=3;i++)
         dp[1][i][0]=1; //the turning point for the beginning must be rising.
     for(ll x=2;x<=20;x++)
     for(ll y=1;y<=4;y++)
     for(ll t=0;t<=10;t++)
     for(ll h=1;h<=4;h++)
     {
         if(x==2)
         {
             if(y>h)
             {
                 if(t%2)
                     dp[2][y][t+1]+=dp[1][h][t];
                 else
                     dp[2][y][t]+=dp[1][h][t];
             }
                 }
         else
             {
                 if(t%2)
             {
                 if(h>y)
                     dp[x][y][t]+=dp[x-1][h][t];
                 else if(h<y)
                     dp[x][y][t+1]+=dp[x-1][h][t];
             }
             else
             {
                 if(h<y)
                     dp[x][y][t]+=dp[x-1][h][t];
                 else if(h>y)
                     dp[x][y][t+1]+=dp[x-1][h][t];
             }
             }
     }
     ll n,t;
     cin>>n>>t;
    ll ans=0;
    for(ll i=1;i<=4;i++)
        ans+=dp[n][i][2*t-1];
    cout<<ans<<endl;
    cout.flush();
 }

#include <iostream>
#include <vector>

using namespace std;

int allCount;

void rec(vector<int>& cur, int n, int t, int pos, int curUp, int curDown) {
    if (pos == n) {
        if (curUp == t && curDown == t - 1) {
            ++allCount;
        }
        return;
    }

    if (curUp > t || curDown > t - 1){
        return;
    }

    if (pos == 0) {
        for (int y = 1; y <= 4; ++y) {
            cur[pos] = y;
            rec(cur, n, t, pos + 1, curUp, curDown);
        }
    } else {
        for (int y = 1; y <= 4; ++y) {
            if (cur[pos - 1] == y) {
                continue;
            }

            int was = cur[pos - 1];
            cur[pos] = y;

            if (y > was) {
                rec(cur, n, t, pos + 1, curUp, curDown + 1);
            } else {
                rec(cur, n, t, pos + 1, curUp + 1, curDown);
            }
        }
    }
}

int main(int argc, char** argv)
{
    const int MAX = 22;

    int N, T;
    cin >> N >> T;
    T = 2 * T + 1;

    int H = 4;
    int f[MAX][MAX][MAX];
    for (int n = 0; n < MAX; ++n)
        for (int t = 0; t < MAX; ++t)
            for (int h = 0; h < MAX; ++h)
                f[n][t][h] = 0;

    for (int h = 1; h <= H; ++h) {
        f[N][T][h] = 1;
    }

    for (int h = 1; h <= H; ++h) {
        for (int t = 0; t < T; ++t) {
            f[N][t][h] = 0;
        }
    }

    for (int n = N - 1; n >= 0; --n) {
        for (int t = 0; t <= T; ++t) {
            for (int h = 1; h <= H; ++h) {
                if (t % 2 == 0) {
                    for (int nh = 1; nh < h; ++nh) {
                        f[n][t][h] += f[n + 1][t + 1][h];
                    }
                    for (int nh = h + 1; nh <= H; ++nh) {
                        f[n][t][h] += f[n + 1][t][h];
                    }
                } else {
                    for (int nh = 1; nh < h; ++nh) {
                        f[n][t][h] += f[n + 1][t][h];
                    }
                    for (int nh = h + 1; nh <= H; ++nh) {
                        f[n][t][h] += f[n + 1][t + 1][h];
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int h = 1; h <= H; ++h) {
        ans += f[2][0][h];
    }
    cout << ans;

    return 0;
}

#include <fstream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>

using namespace std;

#define VI vector<int>
#define VS vector<string>
#define LL long long
#define FOR(i,n,m) for(int i=n;i<=m;i++)
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPD(i,n) for(int i = n - 1; i>=0; i--)
#define BE(a) a.begin(), a.end()
#define PB push_back
#define SQR(x) ((x)*(x))
#define MP make_pair
#define PII pair<int>
#define SI(a) sizeof(a)
#define FE(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)

const int INFI = 2000000000;
const int goX[4] = {-1, 0, 1, 0};
const int goY[4] = {0, 1, 0, -1};

const string PROBLEM_NAME = "E";
const string INPUT_FILE = PROBLEM_NAME + ".in";
const string OUTPUT_FILE = PROBLEM_NAME + ".out";

class State{
public:
    int n, t, start, p0;

    State(){}
    State(int n, int t, int start, int p0) : n(n), t(t), start(start), p0(p0){}

    bool operator<(const State& other) const{
        if (n != other.n) return n < other.n;
        if (t != other.t) return t < other.t;
        if (start != other.start) return start < other.start;
        return p0 < other.p0;
    }
};

int N, T;
map<State, LL> cache;
int a[1000];
LL checkRes;

void read_input(){
    freopen (INPUT_FILE.c_str(),"r",stdin);
    //freopen (OUTPUT_FILE.c_str(),"w",stdout);
}

LL solve(int n, int t, int start, int p0){
    State cur(n, t, start, p0);
    if (cache.find(cur) != cache.end()) return cache[cur];

    LL ret = 0;
    if (t == 0){
        if (n <= 0)  {
            int k = 0;
            if (a[N - 1] > a[N]) k = 1;
            else k = -1;
            int tt = T;
            for (int i = N - 2; i >= 1; i--){
                if (k == 1 && a[i] < a[i + 1]) tt --;
                if (a[i] < a[i + 1]) k = -1; else k = 1;
            }
            //if (tt != 0)  cout << "AAAAAA" << endl;
            return 1;
        }
        if (start != 4 && p0 != -1) {
            FOR(i, start + 1, 4) {
                a[n] = i;
                ret += solve(n - 1, 0, i, 1);
            }
        }
        if (start != 1 && p0 != 1){
            for (int i = start - 1; i >= 1; i--) {
                a[n] = i;
                ret += solve(n - 1, 0, i, -1);
            }
        }
        cache[cur] = ret;
        return ret;
    }
    if (n == 0) {
        cache[cur] = 0;
        return 0;
    }

    if (a[13] == 1 && a[12] == 2 && a[11] == 3 && a[10] == 4 && a[9] == 3 && a[8] == 2) /// && a[7] == 1 && a[6] == 2 && a[5] == 3 && a[4] == 4 && a[3] == 3 && a[2] == 2)
        cout << "";
    if (n == 2 && t == 1)
        cout << "";

    FOR(i, 1, 4) if (i != start){
        if (i > start){
            a[n] = i;
            ret += solve(n - 1, t, i, 1);
        } else if (p0 != 0){
            a[n] = i;
            if (p0 == 1) ret += solve(n - 1, t - 1, i, -1);
            else ret += solve(n - 1, t, i, -1);
        }
    }
    if (ret != 0)
        cout << "";

    cache[cur] = ret;
    return ret;
}

void m_main(){
    cin >> N >> T;
    LL res = 0;

    cache.clear();
    FOR(i, 1, 4) {
        a[N] = i;
        res += solve(N - 1, T, i, 0);
    }

    cout << res << endl;
}

int main(){
    read_input();
    m_main();

    return 0;
}

#include<cstdio>
#include<string.h>
#include<iostream>
using namespace std;

long long int memo[22][5][5][12][11];
int N,T;

long long int solve(int idx,int prev_h,int curr_h,int humps,int dip)
{
    if(idx==N-1)
    {
        if(humps==T && dip==T-1)
        return 1;
        else
        return 0;
    }
    if(humps>T || dip>T-1)
    return 0;
    if(memo[idx][prev_h][curr_h][humps][dip]!=-1)
    return memo[idx][prev_h][curr_h][humps][dip];

    long long int ways=0;
    for(int i=1;i<=4;i++)
    {
        if(i==curr_h)continue;
        ways+=solve(idx+1,curr_h,i,(prev_h<curr_h && curr_h>i && prev_h!=0?humps+1:humps),(prev_h>curr_h && curr_h<i && prev_h!=0?dip+1:dip));
    }
    return memo[idx][prev_h][curr_h][humps][dip]=ways;
}

int main()
{
    int cases;
    scanf("%d",&cases);
    while(cases--)
    {
        scanf("%d %d",&N,&T);
        for(int i=0;i<N;i++)
        for(int j=0;j<=4;j++)
        for(int k=0;k<=4;k++)
        for(int x=0;x<T+1;x++)
        for(int y=0;y<T;y++)
        memo[i][j][k][x][y]=-1;

        long long int ans=0;
        for(int h=1;h<=4;h++)
        ans+=solve(0,0,h,0,0);
        cout<<ans<<endl;
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b;
    cin>>a>>b;
    if(a%b==0) cout<<"0";
    else cout<<a;
}

#include <iostream>
#define maxn 20
#define maxt 10
#define maxh 4

using namespace std;

int n, t;

int mas[maxt][maxn][maxh];

long long facts[2*maxh + 2];

void fill_facts()
{
    facts[0] = 1;
    for (int i = 1; i <= 2*maxh + 1; ++i)
        facts[i] = i*facts[i-1];
}

long long C(int n, int k)
{
    if (n < k)
        return 0;
    else return facts[n]/(facts[n-k]*facts[k]);
}

int solve1(int ti, int li, int hi)
{
    if (mas[ti][li][hi] >= 0)
        return mas[ti][li][hi];

    if (ti == 0 && li == 1)
        return (mas[ti][li][hi] = 1);

    if (li < 3 || hi == maxh || ti == 0)
        return mas[ti][li][hi] = 0;

    mas[ti][li][hi] = 0;
    // 4 - hi x li - 2 -- all pts for spike

    // spl = 1, is the starting point
    long long c1, c2;
    for (int spl = 2; spl <= li - 1; ++spl)
        for (int sph = hi + 1; sph <= maxh; ++sph)
        {
            //C(sph - hi - 1, spl - 2)
            // some spikes cannot be, which ones?
            c1 = C(sph - hi - 1, spl - 2);
            // spike coords (spl, sph), going down now
            for (int dl = spl + 1; dl <= li; ++dl)
                for (int dh = 1; dh <= sph - 1; ++dh)
                {
                    //C(sph - dh - 1, dl - spl - 1)
                    c2 = C(sph - dh - 1, dl - spl - 1);
//                    cout << c1 << " " << c2 << endl;
                    mas[ti][li][hi] += c1*c2*solve1(ti - 1, li - dl + 1, dh);
                }
        }
    return mas[ti][li][hi];
}

int main()
{
    cin >> n >> t;
    int res = 0;
    fill_facts();

    for (int i = 0; i < maxt; ++i)
        for (int j = 0; j < maxn; ++j)
            for (int k = 0; k < maxh; ++k)
                mas[i][j][k] = -1;

    for (int hi = 1; hi <= maxh; ++hi)
    {
        res += solve1(t, n, hi);
        //        cout << res << " " << hi << endl;
    }

    cout << res << endl;

    return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// ----------------------------------------Defines and Template-------------------------------------//
//#define int long long
#define ll long long
#define double long double
#define fs first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).

#define setitr set <int, greater <int> > :: iterator
#define RE(i,n) for(int i=1; i<=n; i++)
#define REP(i,j,n) for(int i=j; i<=n; i++)
#define REB(i,j,n) for(int i=j; i>=n; i--)
#define FO(i,n) for(int i=n; i>0; i--)

const int mod = 1e9+7;
const int INF = 1e8;
const int LGN = 30;

//-------------------------------------------------Template Ends------------------------------------------------------/
int dp[23][5][12][12][2]={-1},t,n;
//dp[i][h][j][k][l] - Answer from (1,smthing) to (i,h) with j ups n k downs with last one as up/down.
//l==1 - Last down, l==0 - last up

int f(int i, int up, int down, int h, int l)
{
    if(i==n)
    {
        if(up==t && down==t-1)
        {
            return dp[i][h][up][down][l] = 1;
        }
        return dp[i][h][up][down][l] = 0;
    }
    if(dp[i][h][up][down][l]!=-1) return dp[i][h][up][down][l];
    if(up+down > (2*t-1)) return 0;
    int &ret = dp[i][h][up][down][l];
    ret = 0;
    if(l==0) //Last was down.
    {
        RE(nh,4)
        {
            if(nh>h) ret += f(i+1,up,down,nh,l);
            if(nh<h) ret += f(i+1,up+1,down,nh,!l);
        }
    }
    else
    {
        RE(nh,4)
        {
            if(nh>h) ret += f(i+1,up,down+1,nh,!l);
            if(nh<h) ret += f(i+1,up,down,nh,l);
        }
    }
    return dp[i][h][up][down][l] = ret;
}

void solve_case()
{
    int i,j,k,m;
    cin >> n >> t;
    if(2*t-1>=n-1)
    {
        cout << 0 << "\n";
        return;
    }
    REP(i,0,n)
    {
        REP(j,0,t) REP(k,0,t) RE(m,4) dp[i][m][j][k][0] = -1, dp[i][m][j][k][1] = -1;
    }
    int ans = 0;
    RE(i,4) ans += f(1,0,0,i,0) + f(1,0,0,i,1);
    cout << ans << "\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    int Testcases = 1;
    //cin >> Testcases;
    while(Testcases--)
    {
        solve_case();
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

long long dp[25][15][6];

int main(){
    ios_base::sync_with_stdio(false);
    int n, t; cin >> n >> t; int T = 2*t-1;
    for(int i=1; i<=4; i++) dp[n][T][i] = 1;
    for(int i=0; i<T; i++)
        for(int j=1; j<=4; j++) dp[n][i][j] = 0;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=4; j++) dp[i][T+1][j] = 0;
    for(int i=n-1; i>=0; i--)
        for(int j=0; j<=T; j++)
            for(int k=1; k<=4; k++){
                long long sum = 0;
                if(j&1){
                    for(int h=k+1; h<=4; h++)
                        sum += dp[i+1][j+1][h];
                    for(int h=1; h<=k-1; h++)
                        sum += dp[i+1][j][h];
                }
                else{
                    for(int h=k+1; h<=4; h++)
                        sum += dp[i+1][j][h];
                    for(int h=1; h<=k-1; h++)
                        sum += dp[i+1][j+1][h];
                }
                dp[i][j][k] = sum;
            }
    long long res = 0;
    for(int i=1; i<=4; i++)
        res += (i-1)*dp[2][0][i];
    cout << res << '\n';
    return 0;
}

#include <iostream>
#include <cstdio>

using namespace std;
const int maxn = 22;
const int maxm = 12;

int n,m;
int f[maxn][maxm][6];

int main()
{
	freopen("14E.in","r",stdin);
	freopen("14E.out","w",stdout);

	cin>>n>>m;

	if(n<=2*m)
	{
		cout<<0<<endl;
		return 0;
	}

	for(int k=1;k<=4;k++)
		f[n][m][k]=1;

	for(int i=n-1;i>=2;i--)
		for(int j=m;j>=0;j--)
			for(int k=1;k<=4;k++)
			{
				if(j%2==0)
				{
					for(int p=k+1;p<=4;p++)
						f[i][j][k]+=f[i+1][j][p];
					for(int p=1;p<k;p++)
						f[i][j][k]+=f[i+1][j+1][p];
				}
				else
				{
					for(int p=k+1;p<=4;p++)
						f[i][j][k]+=f[i+1][j+1][p];
					for(int p=1;p<k;p++)
						f[i][j][k]+=f[i+1][j][p];
				}
			}

	int ans=0;
	for(int k=2;k<=4;k++)
		ans+=(k-1)*f[2][0][k];

	cout<<ans<<endl;

	return 0;
}

#include <bits/stdc++.h>

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.1415926535897932384626

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

LL dp[21][5][2][13];

int n, t;

int main(){
	scanf("%d %d", &n, &t);
	FI(i, 1, 4) dp[1][i][0][0] = 1;
	FI(i, 2, n) FI(j, 1, 4) FI(dir, 0, 1) FI(k, 0, t){
		if(dp[i - 1][j][dir][k] == 0) continue;
		FI(nj, 1, 4){
			if(j == nj) continue;
			int ndir = nj < j;
			if(dir == 0 && ndir == 1 && i > 2){
				dp[i][nj][ndir][k + 1] += dp[i - 1][j][dir][k];
			}
			else{
				dp[i][nj][ndir][k] += dp[i - 1][j][dir][k];
			}
		}
	}

	LL res = 0;
	FI(j, 1, 4) res += dp[n][j][1][t];
	printf("%lld\n", res);
	return 0;
}

/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=20,MAXDIG=4,MAXT=10;
typedef long long ll;
ll dp[MAXN+5][MAXDIG+5][MAXT+5][2];
//dp[i][j][k][r] 第i个数为j时在第k个驼峰上处于 r=1上升,r=0下降 状态
int main()
{
	int n,t;scanf("%d%d",&n,&t);
	dp[2][2][1][1]=1;//1 2
	dp[2][3][1][1]=2;//1 3/2 3
	dp[2][4][1][1]=3;
	for(int i=3;i<=n;i++)
		for(int j=1;j<=4;j++)
			for(int k=0;k<=t;k++)
				for(int r=1;r<=4;r++) //上一个数字
				{
					if(r<j)
						dp[i][j][k][1]+=dp[i-1][r][k][1];
					if(r>j && k>0)
						dp[i][j][k][1]+=dp[i-1][r][k-1][0];
					if(r>j)
						dp[i][j][k][0]+=dp[i-1][r][k][0],
						dp[i][j][k][0]+=dp[i-1][r][k][1];
				}
	ll ans=0;
	for(int i=1;i<=4;i++)
		ans+=dp[n][i][t][0];
	printf("%lld\n",ans);
	return 0;
}

#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <stack>
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
typedef pair<ii, int> iii;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define red(i, a, b) for(int i = a; i > b; i--)
#define RED true
#define BLACK false
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int N = 21;
const int M = 1000 + 1;
const int inf = 1e9 + 7;
const ll base = 1e18;

ll dp[N][N][5][2];
int n, t;

int main() {
    cin >> n >> t;
    rep(i, 1, 5)
        dp[1][0][i][0] = 1;
    rep(i, 2, n + 1){
        rep(u, 1, 5){
            rep(v, u + 1, 5)
                dp[i][0][v][0] += dp[i-1][0][u][0];
        }
        rep(j, 1, t + 1){
            rep(u, 1, 5){
                rep(v, 1, 5){
                    if (u == v) continue;
                    if (u > v){
                        dp[i][t][u][0] += dp[i-1][t][v][0];
                        dp[i][t][u][0] += dp[i-1][t-1][v][1];
                    }else{
                        dp[i][t][u][1] += dp[i-1][t][v][1];
                        dp[i][t][u][1] += dp[i-1][t-1][v][0];
                    }
                }
            }
        }
    }
    ll res = 0;
    rep(i, 1, 5)
        res += dp[n][2*t-1][i][1];
    cout<<res<<endl;

}

/**
    http://codeforces.com/blog/entry/389
*/

# include <bits/stdc++.h>

typedef long long int lli;

const int maxn = 25;
const int maxt = 15;
const int maxh = 5;

int n, t, h;
lli f[maxn][maxt][maxh];

int main()
{
   // freopen("out2.txt", "w", stdout);
   // for (n = 3; n <= 20; ++n) {
    //for (t = 1; t <= 10; ++t) {

  //  printf("%d %d \t", n, t);

    h = 4;
    scanf("%d%d", &n, &t);
    memset(f, 0, sizeof(f));

    int T = 2*t-1;

    if (n+2 < T) {printf("0\n"); return 0;}

    for (int i = 0; i < h; ++i) {
        f[n][T][i] = 1;
    }

    for (int i = n-1; i >= 1; --i) {
        for (int j = 0; j <= T; ++j) {
            for (int k = 0; k < h; ++k) {
                f[i][j][k] = 0;
                if (j%2 == 0) {
                    for (int l = k+1; l < h; ++l) f[i][j][k] += f[i+1][j][l];
                    for (int l = 0; l < k; ++l) f[i][j][k] += f[i+1][j+1][l];
                } else {
                    for (int l = k+1; l < h; ++l) f[i][j][k] += f[i+1][j+1][l];
                    for (int l = 0; l < k; ++l) f[i][j][k] += f[i+1][j][l];
                }
            }
        }
    }

    lli ans = 0;
    for (int i = 0; i < h; ++i) ans += i * f[2][0][i];
    std::cout << ans << std::endl;

   // }
   // }
    return 0;
}

#include <iostream>
#include <cstring>
using namespace std;
int dp[30][5][20][2];
int main() {
    int n , t;
    cin >> n >> t;
    memset(dp , 0 , sizeof(dp));
    for(int now = 1 ; now <= 4 ; now++) {
        dp[1][now][1][1] = 1;
    }
    for(int i = 2 ; i <= n ; i++) {
        for(int num = 1 ; num <= t ; num++) {
            for(int now = 1 ; now <= 4 ; now++) {
                for(int pre = 1 ; pre <= 4 ; pre++) {
                    if(now > pre) {
                        dp[i][now][num][1] += dp[i - 1][pre][num][1] + dp[i - 1][pre][num - 1][0];
                    }
                    if(now < pre) {
                        dp[i][now][num][0] += dp[i - 1][pre][num][1] + dp[i - 1][pre][num][0];
                    }
                }
            }
        }
    }
    int sum = 0;
    for(int now = 1 ; now <= 4 ; now++) {
        sum += dp[n][now][t][0];
    }
    cout << sum << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ls l,mid,rt<<1
#define rs mid+1,r,rt<<1|1
#define de(x) cout<< #x<<" = "<<x<<endl
#define dd(x) cout<< #x<<" = "<<x<<" "
#define sf scanf
#define pf printf
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef long double ld;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const double PI=acos(-1.0);
const int MAXN=25;
const int MOD=1e9+7;
int sgn(double x){if(fabs(x)<eps)return 0;if(x<0)return -1;else return 1;}
ll pw(ll a,ll n,ll mod){ll ret=1;while(n){if(n&1)ret=ret*a%mod;a=a*a%mod;n>>=1;}return ret;}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
//head

int n,t;
ll dp[MAXN][5][MAXN];

void gao(int a,int b,int c){
    if(c&1){
        for(int j=1;j<b;j++)dp[a+1][j][c]+=dp[a][b][c];
        for(int j=b+1;j<=4;j++)dp[a+1][j][c+1]+=dp[a][b][c];
    }else{
        for(int j=1;j<b;j++)dp[a+1][j][c+1]+=dp[a][b][c];
        for(int j=b+1;j<=4;j++)dp[a+1][j][c]+=dp[a][b][c];
    }
}

int main(){
    sf("%d%d",&n,&t);t=2*t-1;
    for(int j=1;j<=4;j++)dp[1][j][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=4;j++)
            for(int k=0;k<=min(i/2,t);k++)
                gao(i,j,k);
    ll ans=0;
    for(int j=1;j<=4;j++)ans+=dp[n][j][t];
    pf("%I64d\n",ans);
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAXH  = 5;
const int MAXM  = 11;
const int MAXN  = 21;

int n, t;

int f[MAXN][MAXM][MAXH][MAXH];

bool Input(void) {
        if( EOF == scanf("%d %d", &n, &t) ) {
                return false;
        }
        return true;
}

inline int Opt(int len, int cnt, int HL, int HR) {
        int &ans = f[len][cnt][HL][HR];
        if( -1 != ans ) {
                return ans;
        }

        // if( HR-HL+1 < 2*cnt+1 ) {
        //         return ans = 0;
        // }
        if( 1 == cnt ) {
                ans = 0;
                for(int topIdx = 2; topIdx < len; topIdx ++) {
                        for(int topH = 3; topH <= 4; topH ++) {
                                int tmp = 0;
                                if( topIdx-1 > topH-HL || len-topIdx > topH-HR )  {
                                        continue;
                                }
                                if( topIdx-1 == 2 && topH-HL == 3 ) {
                                        tmp += 2;
                                }
                                if( len-topIdx == 2 && topH-HR == 3 ) {
                                        tmp += 2;
                                }
                                if( !tmp ) {
                                        tmp += 1;
                                }
                                ans += tmp;
                        }
                }
                //printf("f[%d][%d][%d][%d] = %d\n", len, cnt, HL, HR, ans);
                return ans;
        }

        ans = 0;
        for(int k = 1; k < len; k ++) {
                for(int L = 1; L <= 4; L ++) {
                        ans += Opt(len-k, cnt-1, HL, L)*Opt(k, 1, L, HR);
                }
        }
        //printf("f[%d][%d][%d][%d] = %d\n", len, cnt, HL, HR, ans);
        return ans;
}

int Process(void) {
        int ans = 0;
        //printf("n = %d, t = %d\n", n, t);
        for(int hl = 1; hl <= 4; hl ++) {
                for(int hr = 1; hr <= 4; hr ++) {
                        ans += Opt(n, t, hl, hr);
                }
        }
        return ans;
}

int main(int argc, char const *argv[])
{
        //freopen("test.in", "r", stdin);
        memset(f, -1, sizeof(f));
        while( true == Input() ) {
                printf("%d\n", Process());
        }
        return 0;
}

#include <bits/stdc++.h>
#define MAX_N 23
#define MAX_T 11

using namespace std;

typedef unsigned long long ull;

ull dp[MAX_N][MAX_T][MAX_T][4][4];
int n,t;

int main ()
	{
		ios :: sync_with_stdio(false);
		cin.tie(0);

		cin >> n >> t;

		for (int now = 0; now < 4; now++)
			for (int prev = 0; prev < 4; prev++)
				dp[2][0][0][now][prev] = (now != prev);

		for (int i = 3; i <= n; i++)
			for (int x = 0; x <= t; x++)
				for (int y = 0; y <= t; y++)
					for (int now = 0; now < 4; now++)
						for (int prev = 0; prev < 4; prev++)
							if (now != prev)
								{
									if (now < prev)
										for (int l = 0; l < 4; l++)
											if (l != prev)
												dp[i][x][y][now][prev] += (l < prev) ? dp[i-1][x-1][y][prev][l] : dp[i-1][x][y][prev][l];

									if (now > prev)
										for (int l = 0; l < 4; l++)
											if (l != prev)
												dp[i][x][y][now][prev] += (l > prev) ? dp[i-1][x][y-1][prev][l] : dp[i-1][x][y][prev][l];
								}

		ull res = 0;
		for (int now = 0; now < 4; now++)
			for (int prev = 0; prev < 4; prev++)
				if (now != prev)
					res += dp[n][t][t-1][now][prev];
		return 0;
	}

#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int N, T;
lli dps[21][11][5];
lli dp(int n, int t, int h){
  lli s = 0;
  if(dps[n][t][h] != -1)
    return dps[n][t][h];
  if(n == N && t == T){
    dps[n][t][h] = 1;
    return 1;
  }
  else if(n >= N){
    dps[n][t][h] = 0;
    return 0;
  }
  else if(t == T + 1){
    dps[n][t][h] = 0;
    return 0;
  }

  if(t%2){
    for(int i = h + 1; i <= 4; i++)
      s += dp(n + 1, t + 1, i);
    for(int i = 1; i < h; i++)
      s += dp(n + 1, t, i);
  }
  else{
    for(int i = h + 1; i <= 4; i++)
      s += dp(n + 1, t, i);
    for(int i = 1; i < h; i++)
      s += dp(n + 1, t + 1, i);
  }
  dps[n][t][h] = s;
  return s;
}

int main(){
  lli s = 0;
  scanf("%d %d", &N, &T);
  for(int i = 0; i < 21; i++)
    for(int j = 0; j < 11; j++)
      for(int k = 0; k < 5; k++)
	dps[i][j][k] = -1;
  T = 2*T - 1;
  for(int i = 1; i <= 4; i++)
    s += (i -1)*dp(2, 0, i);
  printf("%lld\n", s);
  return 0;
}

# include <stdio.h>
# include <stdlib.h>
# include <iostream>

using namespace std;

# define MAX 30

// 0 ABAJO
// 1 ARRIBA

long long DP[ MAX ][ MAX ][ MAX ][ 2 ];

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	long long N, T, SOLUTION = 0;
	cin >> N >> T;

	for( int i = 1 ; i <= N ; i++ ){

		// Base case //
		for( int t = 0 ; t <= T ; t++ ){

			for( int h = 1 ; h <= 4 ; h ++ ){

				if( i == 1 && t == 0 ){
					DP[ i ][ t ][ h ][ 0 ] = 1;
					DP[ i ][ t ][ h ][ 1 ] = 1;
				}else if( i > 0 ){

					for( int k = 1; k <= 4 ; k ++ ){

						if( k > h ){

							DP[ i ][ t ][ h ][ 1 ] += DP[ i - 1 ][ t ][ k ][ 1 ];

							if( t > 0 )
								DP[ i ][ t ][ h ][ 1 ] += DP[ i - 1 ][ t - 1 ][ k ][ 0 ];

						}else if( k < h ){
							DP[ i ][ t ][ h ][ 0 ] += DP[ i - 1 ][ t ][ k ][ 0 ];
						}

					}

				}

				//cout << i << " " << t << " " << h << " " << DP[ i ][ t ][ h ][ 0 ] << " " << DP[ i ][ t ][ h ][ 1 ] << endl;
				//getchar();

				if( i == N && T == t ){
					SOLUTION += DP[ i ][ t ][ h ][ 1 ];
				}

			}

		}

	}

	cout << SOLUTION << endl;

	return 0;
}

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#define N 22
#define INF 0x6f6f6f6f
#define debug(a) cout<<#a<<' '<<a<<endl;
typedef long long LL;
using namespace std;
LL dp[N][13][5][2];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
    int n,t;
    while(scanf("%d %d",&n,&t)!=EOF)
    {
        memset(dp,0,sizeof(dp));
        for(int i=1;i<=4;i++)
            dp[1][0][i][0]=1;
        for(int i=1;i<n;i++)
            for(int j=0;j<=i/2 && j<=t;j++)
                for(int k=1;k<=4;k++)
                {
                    if(dp[i][j][k][0])
                    {
                        for(int a=k+1;a<=4;a++)
                            dp[i+1][j][a][0]+=dp[i][j][k][0];
                        if(i!=1)
                        for(int a=1;a<k;a++)
                            dp[i+1][j+1][a][1]+=dp[i][j][k][0];
                    }
                    if(dp[i][j][k][1])
                    {
                        for(int a=1;a<k;a++)
                            dp[i+1][j][a][1]+=dp[i][j][k][1];
                        for(int a=k+1;a<=4;a++)
                            dp[i+1][j+1][a][0]+=dp[i][j][k][1];
                    }
                }
        LL ans=0;
        for(int i=1;i<=4;i++)
            ans+=dp[n][t][i][1];
        cout<<ans<<endl;
    }
	return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAXH  = 5;
const int MAXM  = 11;
const int MAXN  = 21;

int n, t;

int f[MAXN][MAXM][MAXH][MAXH];

bool Input(void) {
        if( EOF == scanf("%d %d", &n, &t) ) {
                return false;
        }
        return true;
}

inline int Opt(int len, int cnt, int HL, int HR) {
        int &ans = f[len][cnt][HL][HR];
        if( -1 != ans ) {
                return ans;
        }

        // if( HR-HL+1 < 2*cnt+1 ) {
        //         return ans = 0;
        // }
        if( 1 == cnt ) {
                ans = 0;
                for(int topIdx = 2; topIdx < len; topIdx ++) {
                        for(int topH = 2; topH <= 4; topH ++) {
                                int tmp = 0;
                                if( topIdx-1 > topH-HL || len-topIdx > topH-HR )  {
                                        continue;
                                }
                                if( topIdx-1 == 2 && topH-HL == 3 ) {
                                        tmp += 2;
                                }
                                if( len-topIdx == 2 && topH-HR == 3 ) {
                                        tmp += 2;
                                }
                                if( !tmp ) {
                                        tmp += 1;
                                }
                                ans += tmp;
                        }
                }
                //printf("f[%d][%d][%d][%d] = %d\n", len, cnt, HL, HR, ans);
                return ans;
        }

        ans = 0;
        for(int k = 1; k < len; k ++) {
                for(int L = 1; L <= 4; L ++) {
                        ans += Opt(len-k, cnt-1, HL, L)*Opt(k, 1, L, HR);
                }
        }
        //printf("f[%d][%d][%d][%d] = %d\n", len, cnt, HL, HR, ans);
        return ans;
}

int Process(void) {
        int ans = 0;
        //printf("n = %d, t = %d\n", n, t);
        for(int hl = 1; hl <= 4; hl ++) {
                for(int hr = 1; hr <= 4; hr ++) {
                        ans += Opt(n, t, hl, hr);
                }
        }
        return ans;
}

int main(int argc, char const *argv[])
{
        //freopen("test.in", "r", stdin);
        memset(f, -1, sizeof(f));
        while( true == Input() ) {
                printf("%d\n", Process());
        }
        return 0;
}

/**
    http://codeforces.com/blog/entry/389
*/

# include <bits/stdc++.h>

typedef long long int lli;

const int maxn = 25;
const int maxt = 15;
const int maxh = 5;

int n, t, h;
lli f[maxn][maxt][maxh];

int main()
{
    scanf("%d%d", &n, &t); h = 4;
    int T = 2*t-1;
    for (int i = 0; i < h; ++i) {
        f[n][T][i] = 1;
        f[n][T+1][i] = 0;
    }
    for (int i = 0; i < T; ++i) {
        for (int j = 0; j < h; ++j) {
            f[n][i][j] = 0;
        }
    }

    for (int i = n-1; i >= 1; --i) {
        for (int j = 0; j <= T; ++j) {
            for (int k = 0; k < h; ++k) {
                f[i][j][k] = 0;
                if (j%2 == 0) {
                    for (int l = k+1; l < h; ++l) f[i][j][k] += f[i+1][j][l];
                    for (int l = 0; l < k; ++l) f[i][j][k] += f[i+1][j+1][l];
                } else {
                    for (int l = k+1; l < h; ++l) f[i][j][k] += f[i+1][j+1][l];
                    for (int l = 0; l < k; ++l) f[i][j][k] += f[i+1][j][l];
                }
            }
        }
    }

    lli ans = 0;
    for (int i = 0; i < h; ++i) ans += i * f[2][0][i];
    printf("%I64d\n", ans);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ls l,mid,rt<<1
#define rs mid+1,r,rt<<1|1
#define de(x) cout<< #x<<" = "<<x<<endl
#define dd(x) cout<< #x<<" = "<<x<<" "
#define sf scanf
#define pf printf
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef long double ld;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const double PI=acos(-1.0);
const int MAXN=25;
const int MOD=1e9+7;
int sgn(double x){if(fabs(x)<eps)return 0;if(x<0)return -1;else return 1;}
ll pw(ll a,ll n,ll mod){ll ret=1;while(n){if(n&1)ret=ret*a%mod;a=a*a%mod;n>>=1;}return ret;}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
//head

int n,t;
ll dp[MAXN][5][MAXN];

void gao(int a,int b,int c){
    if(c&1){
        for(int j=1;j<b;j++)dp[a+1][j][c]+=dp[a][b][c];
        for(int j=b+1;j<=4;j++)dp[a+1][j][c+1]+=dp[a][b][c];
    }else{
        for(int j=1;j<b;j++)dp[a+1][j][c+1]+=dp[a][b][c];
        for(int j=b+1;j<=4;j++)dp[a+1][j][c]+=dp[a][b][c];
    }
}

int main(){
    sf("%d%d",&n,&t);t=2*t-1;
    for(int j=1;j<=3;j++)dp[1][j][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=4;j++)
            for(int k=0;k<=min((i-1)/2,t);k++)
                gao(i,j,k);
    ll ans=0;
    for(int j=1;j<=3;j++)ans+=dp[n][j][t];
    pf("%I64d\n",ans);
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[21][4][11]; // Let dp[x][y][t] be the total number of t turning points when the last point falls on (x,y)
int main()
 {
     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
     memset(dp,0,sizeof(dp));
     for(ll i=1;i<=3;i++)
         dp[1][i][0]=1; //the turning point for the beginning must be rising.
     for(ll x=2;x<=20;x++)
     for(ll y=1;y<=4;y++)
     for(ll t=0;t<=10;t++)
     for(ll h=1;h<=4;h++)
     {
         if(x==2)
         {
             if(y>h)
             {
                 if(t%2)
                     dp[2][y][t+1]+=dp[1][h][t];
                 else
                     dp[2][y][t]+=dp[1][h][t];
             }
                 }
         else
             {
                 if(t%2)
             {
                 if(h>y)
                     dp[x][y][t]+=dp[x-1][h][t];
                 else if(h<y)
                     dp[x][y][t+1]+=dp[x-1][h][t];
             }
             else
             {
                 if(h<y)
                     dp[x][y][t]+=dp[x-1][h][t];
                 else if(h>y)
                     dp[x][y][t+1]+=dp[x-1][h][t];
             }
             }
     }
     ll n,t;
     cin>>n>>t;
    ll ans=0;
    for(ll i=1;i<=4;i++)
        ans+=dp[n][i][2*t-1];
    cout<<ans<<endl;
    cout.flush();
 }

#include<cstdio>
#include<string.h>
#include<iostream>
using namespace std;

long long int memo[22][5][5][12][11];
int N,T;

long long int solve(int n,int prev_h,int curr_h,int humps,int dip)
{
    if(n==N)
    {
        if(humps==T && dip==T-1)
        return 1;
        else
        return 0;
    }
    if(humps>T || dip>T-1)
    return 0;
    if(memo[n][prev_h][curr_h][humps][dip]!=-1)
    return memo[n][prev_h][curr_h][humps][dip];

    long long int ways=0;
    for(int i=1;i<=4;i++)
    {
        if(i==curr_h)continue;
        ways+=solve(n+1,curr_h,i,(prev_h<curr_h && curr_h>i && prev_h!=0?humps+1:humps),(prev_h>curr_h && curr_h<i && prev_h!=0?dip+1:dip));
    }
    return memo[n][prev_h][curr_h][humps][dip]=ways;
}

int main()
{
    int cases;
    scanf("%d",&cases);
    while(cases--)
    {
        scanf("%d %d",&N,&T);
        for(int i=1;i<=N;i++)
        for(int j=0;j<=4;j++)
        for(int k=0;k<=4;k++)
        for(int x=0;x<=T+1;x++)
        for(int y=0;y<=T;y++)
        memo[i][j][k][x][y]=-1;

        long long int ans=0;
        for(int h=1;h<=4;h++)
        ans+=solve(1,0,h,0,0);
        cout<<ans<<endl;
    }
    return 0;
}