#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
long long k, n, m, V[100];
long long Calota(long long x1, long long y1, long long x2, long long y2)
{
long long xm=(x1+x2)/2, ym=(y1+y2)/2;
if (n<=xm && m<=ym)
return 1;
if (n<=xm && ym<m)
return 2;
if (xm<n && m<=ym)
return 3;
if (xm<n && ym<m)
return 4;
}
long long DeI(long long d, long long s, long long x1, long long y1, long long x2, long long y2, long long big)
{
long long xm=(x1+x2)/2, ym=(y1+y2)/2;
if (x1==x2 && y1==y2)
{
return 0;
}
else
{
long long loc=Calota(x1, y1, x2, y2);
if (d==1 && s==0)
{
if (loc==1)
{
return DeI(2, 0, x1, y1, xm, ym, big-1);
}
if (loc==2)
{
return DeI(1, 0, x1, ym+1, xm, y2, big-1) + V[big-1]+1;
}
if (loc==3)
{
return DeI(3, 1, xm+1, y1, x2, ym, big-1) + 3*V[big-1]+3;
}
if (loc==4)
{
return DeI(1, 0, xm+1, ym+1, x2, y2, big-1) + 2*V[big-1]+2;
}
}
if (d==1 && s==1)
{
if (loc==1)
{
return DeI(2, 1, x1, y1, xm, ym, big-1) + 3*V[big-1]+3;
}
if (loc==2)
{
return DeI(1, 1, x1, ym+1, xm, y2, big-1) + 2*V[big-1]+2;
}
if (loc==3)
{
return DeI(3, 0, xm+1, y1, x2, ym, big-1);
}
if (loc==4)
{
return DeI(1, 1, xm+1, ym+1, x2, y2, big-1) + V[big-1]+1;
}
}
if (d==2 && s==0)
{
if (loc==1)
{
return DeI(1, 0, x1, y1, xm, ym, big-1);
}
if (loc==2)
{
return DeI(4, 1, x1, ym+1, xm, y2, big-1) + 3*V[big-1]+3;
}
if (loc==3)
{
return DeI(2, 0, xm+1, y1, x2, ym, big-1) + V[big-1]+1;
}
if (loc==4)
{
return DeI(2, 0, xm+1, ym+1, x2, y2, big-1) + 2*V[big-1]+2;
}
}
if (d==2 && s==1)
{
if (loc==1)
{
return DeI(1, 1, x1, y1, xm, ym, big-1) + 3*V[big-1]+3;
}
if (loc==2)
{
return DeI(4, 0, x1, ym+1, xm, y2, big-1);
}
if (loc==3)
{
return DeI(2, 1, xm+1, y1, x2, ym, big-1) + 2*V[big-1]+2;
}
if (loc==4)
{
return DeI(2, 1, xm+1, ym+1, x2, y2, big-1) + V[big-1] + 1;
}
}
if (d==3 && s==0)
{
if (loc==1)
{
return DeI(3, 0, x1, y1, xm, ym, big-1) + V[big-1] + 1;
}
if (loc==2)
{
return DeI(3, 0, x1, ym+1, xm, y2, big-1) + 2*V[big-1]+2;
}
if (loc==3)
{
return DeI(1, 1, xm+1, y1, x2, ym, big-1);
}
if (loc==4)
{
return DeI(4, 0, xm+1, ym+1, x2, y2, big-1) + 3*V[big-1]+3;
}
}
if (d==3 && s==1)
{
if (loc==1)
{
return DeI(3, 1, x1, y1, xm, ym, big-1) + 2*V[big-1]+2;
}
if (loc==2)
{
return DeI(3, 1, x1, ym+1, xm, y2, big-1) + V[big-1] + 1;
}
if (loc==3)
{
return DeI(1, 0, xm+1, y1, x2, ym, big-1) + 3*V[big-1]+3;
}
if (loc==4)
{
return DeI(4, 1, xm+1, ym+1, x2, y2, big-1);
}
}
if (d==4 && s==0)
{
if (loc==1)
{
return DeI(4, 0, x1, y1, xm, ym, big-1) + V[big-1] + 1;
}
if (loc==2)
{
return DeI(2, 1, x1, ym+1, xm, y2, big-1);
}
if (loc==3)
{
return DeI(4, 0, xm+1, y1, x2, ym, big-1) + 2*V[big-1]+2;
}
if (loc==4)
{
return DeI(3, 0, xm+1, ym+1, x2, y2, big-1) + 3*V[big-1]+3;
}
}
if (d==4 && s==1)
{
if (loc==1)
{
return DeI(4, 1, x1, y1, xm, ym, big-1) + 2*V[big-1]+2;
}
if (loc==2)
{
return DeI(2, 0, x1, ym+1, xm, y2, big-1) + 3*V[big-1]+3;
}
if (loc==3)
{
return DeI(4, 1, xm+1, y1, x2, ym, big-1) + V[big-1] + 1;
}
if (loc==4)
{
return DeI(3, 1, xm+1, ym+1, x2, y2, big-1);
}
}
}
}
void Precalc()
{
int i;
V[0]=0;
V[1]=3;
for (i=2; i<=k; i++)
{
V[i]=V[i-1]*4+3;
}
}
int main()
{
fin>>k>>m>>n;
Precalc();
fout<<DeI(2, 0, 1, 1, pow(2, k), pow(2, k), k);
return 0;
}