#include <bits/stdc++.h>
using namespace std;
long long pw2[100];
int divide(int x, int y, int dim) {
if (dim == 0) {
return 0;
}
if (x <= pw2[dim - 1] && y <= pw2[dim - 1] ) {
return divide(y, x, dim - 1);
}
if (x > pw2[dim - 1] && y <= pw2[dim - 1]) {
return pw2[dim - 1] * pw2[dim - 1] + divide(x - pw2[dim - 1], y, dim - 1);
}
if (x > pw2[dim -1] && y > pw2[dim - 1]) {
return 2 * pw2[dim - 1] * pw2[dim - 1] + divide(x - pw2[dim - 1], y - pw2[dim - 1], dim - 1);
}
return 3 * pw2[dim - 1] * pw2[dim - 1] + divide(pw2[dim - 1] - y + pw2[dim - 1] + 1, pw2[dim - 1] - x + 1, dim - 1);
}
int main()
{
ifstream f("fractal.in");
ofstream g("fractal.out");
pw2[0] = 1;
int x, y, k;
f >> k >> x >> y;
for (int i = 1; i <= 30; i++) {
pw2[i] = 2 * pw2[i - 1];
//cout << pw2[i] << endl;
}
g << divide(x, y, k);
}