#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int main(){ ll N, M, ans=0; cin >> N >> M; if (N < 40) M = min(M, 1LL<<(N-1)); while(M != 1 && N != 0){ ans += M; if (M % 2 == 0) M /= 2; else M = (M+1)/2; N--; } cout << ans+N << endl; return 0; }