#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
using namespace std;
int fractal(int k, int x, int y, int x1, int x2, int y1, int y2, int o) {
if ((x1 == x2) && (y1 == y2))
return 0;
int mean_x = (x1 + x2) / 2;
int mean_y = (y1 + y2) / 2;
int cost = pow(4, (k - 1)) - 1;
int costs[4] = {0, cost + 1, 2 * cost + 2, 3 * cost + 3};
if ((x <= mean_x) && (y <= mean_y)) {
return costs[o % 4] + fractal(k - 1, x, y, x1, mean_x, y1, mean_y, 2);
}
if ((x <= mean_x) && (y > mean_y)) {
return costs[(o + 1) % 4] + fractal(k - 1, x, y, x1, mean_x, mean_y + 1, y2, 2);
}
if ((x > mean_x) && (y > mean_y)) {
return costs[(o + 2) % 4] + fractal(k - 1, x, y, mean_x + 1, x2, mean_y + 1, y2, 3);
}
if ((x > mean_x) && (y <= mean_y)) {
return costs[(o + 3) % 4] + fractal(k - 1, x, y, mean_x + 1, x2, y1, mean_y, 0);
}
return 0;
}
int main() {
ifstream fin("fractal.in");
int k, x, y;
fin >> k >> x >> y;
fin.close();
ofstream fout("fractal.out");
fout << fractal(k, x, y, 1, 1 << k, 1, 1 << k, 0);
fout.close();
return 0;
}