#include <iostream>
using namespace std;
const int N = 3;
int c[N][N];
int fun00();
int fun01(int);
int fun02(int);
int fun10(int);
int fun11(int);
int fun12(int);
int fun(int, int);
int res = 0;
int main()
{
for (int i=0; i<N; i++)
{
for (int j=0; j<N; j++)
{
c[i][j] = 0;
}
}
cout << fun(0, 0) << endl;
return 0;
}
int fun(int i, int j)
{
if ((i < N-1) && (j == N))
{
i++;
j = 0;
}
if ((i == N-1) && (N-1 == j))
{
c[i][j] = 0;
res++;
c[i][j] = 1;
res++;
c[i][j] = 2;
res++;
}
else
{
c[i][j] = 0;
res = fun(i, j+1);
c[i][j] = 1;
res = fun(i, j+1);
c[i][j] = 2;
res = fun(i, j+1);
}
return res;
}
int fun00()
{
int res = 0;
c[0][0] = 0;
res = fun01(res);
c[0][0] = 1;
res = fun01(res);
c[0][0] = 2;
res = fun01(res);
return res;
}
int fun01(int res)
{
c[0][1] = 0;
res = fun02(res);
c[0][1] = 1;
res = fun02(res);
c[0][1] = 2;
res = fun02(res);
return res;
}
int fun02(int res)
{
c[0][2] = 0;
res = fun10(res);
c[0][2] = 1;
res = fun10(res);
c[0][2] = 2;
res = fun10(res);
return res;
}
int fun10(int res)
{
c[1][0] = 0;
res = fun11(res);
c[1][0] = 1;
res = fun11(res);
c[1][0] = 2;
res = fun11(res);
return res;
}
int fun11(int res)
{
c[1][1] = 0;
res = fun12(res);
c[1][1] = 1;
res = fun12(res);
c[1][1] = 2;
res = fun12(res);
return res;
}
int fun12(int res)
{
c[1][2] = 0;
res++;
c[1][2] = 1;
res++;
c[1][2] = 2;
res++;
return res;
}