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