#include <stdio.h>
int K, xst, yst, nrot, res;
int v[4] = {1,2,3,4};
int pow2[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768};
int pow4[] = {0,1,4,16,64,256,1024,4096,16384,65536,262144,1048576,4194304,16777216,67108864,268435456};
FILE *fin = fopen("fractal.in", "rt"), *fout = fopen("fractal.out", "wt");
void calcord(int rot)
{
if (rot == 0) v[0] = 1, v[1] = 2, v[2] = 3, v[3] = 4;
if (rot == 1) v[0] = 3, v[1] = 2, v[2] = 1, v[3] = 4;
if (rot == 2) v[0] = 3, v[1] = 4, v[2] = 1, v[3] = 2;
if (rot == 3) v[0] = 1, v[1] = 4, v[2] = 3, v[3] = 2;
}
void calcnrot(int cad)
{
if (nrot == 0)
{
if (cad == 1) nrot = (3 + nrot) % 4;
else if (cad == 4) nrot = (++nrot) % 4;
return;
}
if (nrot == 1)
{
if (cad == 4) nrot = (3 + nrot) % 4;
else if (cad == 3) nrot = (++nrot) % 4;
return;
}
if (nrot == 2)
{
if (cad == 3) nrot = (3 + nrot) % 4;
else if (cad == 2) nrot = (++nrot) % 4;
return;
}
if (nrot == 3)
{
if (cad == 2) nrot = (3 + nrot) % 4;
else if (cad == 1) nrot = (++nrot) % 4;
return;
}
}
void rec(int k, int x, int y)
{
if (!k) return;
if (x <= pow2[k - 1] && y <= pow2[k - 1])
{
res += (v[0] - 1) * pow4[k];
calcnrot(1);
calcord(nrot);
rec(k - 1, x, y);
}
if (x > pow2[k - 1] && y <= pow2[k - 1])
{
res += (v[1] - 1) * pow4[k];
calcnrot(2);
calcord(nrot);
rec(k - 1, x - pow2[k - 1], y);
}
if (x > pow2[k - 1] && y > pow2[k - 1])
{
res += (v[2] - 1) * pow4[k];
calcnrot(3);
calcord(nrot);
rec(k - 1, x - pow2[k - 1], y - pow2[k - 1]);
}
if (x <= pow2[k - 1] && y > pow2[k - 1])
{
res += (v[3] - 1) * pow4[k];
calcnrot(4);
calcord(nrot);
rec(k - 1, x, y - pow2[k-1]);
}
}
int main()
{
fscanf(fin, "%d %d %d", &K, &yst, &xst);
rec(K, xst, yst);
fprintf(fout, "%d", res);
fclose(fin), fclose(fout);
return 0;
}