#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll=long long; using Graph=vector<vector<pair<int,ll>>>; #define INF 1000000000000000000 #define MOD 998244353 #define MAX 1000000 int main(){ ll N,M; cin>>N>>M; ll ans=0; if(N<=30&&(1<<(N-1))<=M){ ans=(1LL<<N)-1; }else{ while(N>0){ if(M==1){ ans+=N; break; } ans+=M; M=(M+1)/2; N--; } } cout<<ans<<'\n'; }