누가 햄버거를 몇억장씩 패티를 넣어서 파냐...ㅠㅠ
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long d[51];
long long p[51];
long long DFS(int L, long long x) {
if (L == 0) {
if (x == 0) return 0;
else return 1;
}
if (x == 1) return 0;
if (x <= 1 + d[L - 1]) return DFS(L-1,x-1);
if (x == 1 + d[L - 1] + 1) return p[L - 1] + 1;
if (x <= 1 + d[L - 1] + 1 + d[L - 1]) return DFS(L - 1, x - 1 - 1 - d[L - 1]) + p[L - 1] + 1;
else return 2 * p[L - 1] + 1;
}
int main() {
//freopen("in1.txt", "rt", stdin);
long long x;
int n;
cin >> n >> x;
d[0] = 1;
p[0] = 1;
for (int i = 1; i <= n; i++) {
d[i] = 2 * d[i - 1] + 3;
p[i] = 2 * p[i - 1] + 1;
}
cout << DFS(n, x) << '\n';
return 0;
}