#include using namespace std; typedef long long ll; const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; const ll mod = 998244353; int main() { int N, M; cin >> N >> M; ll ans = M; int cnt = 1; while (M > 1) { if (M % 2 == 0) { M /= 2; ans += M; } else { M = M / 2 + 1; ans += M; } cnt++; } while (cnt < N) { cnt++; ans++; } cout << ans << endl; }