#include using namespace std; int main(){ int N, M; cin >> N >> M; bool ok = false; if (N <= 30){ if (M > (1 << N)){ ok = true; } } if (ok){ long long ans = 1; for (int i = 0; i < N; i++){ ans += 1 << i; } cout << ans << endl; } else { long long ans = 0; while (true){ if (M == 1){ ans += N; break; } else { ans += M; M = (M + 1) / 2; N--; } } cout << ans << endl; } }