#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};
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;
/* if (cad == 2)
{
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)
{
// fprintf(fout, "%d\n", 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;
// fprintf(fout, "%d %d %d %d %d\n", k, x, y, nrot, res);
// fprintf(fout, "%d %d %d %d\n", v[0], v[1], v[2], v[3]);
if (x <= pow2[k - 1] && y <= pow2[k - 1])
{
//cadranul I
if (k == 1) res += (v[0] - 1);
else res += (v[0] - 1) * pow2[k];
calcnrot(1);
calcord(nrot);
rec(k - 1, x, y);
}
if (x > pow2[k - 1] && y <= pow2[k - 1])
{
if (k == 1) res += (v[1] - 1);
else res += (v[1] - 1) * pow2[k];
calcnrot(2);
calcord(nrot);
rec(k - 1, x - pow2[k - 1], y);
}
if (x > pow2[k - 1] && y > pow2[k - 1])
{
if (k == 1) res += (v[2] - 1);
else res += (v[2] - 1) * pow2[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])
{
if (k == 1) res += (v[3] - 1);
else res += (v[3] - 1) * pow2[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;
}