#include <bits/stdc++.h>
using namespace std;

#ifdef _RUTHEN
#include "debug.hpp"
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, M;
    cin >> N >> M;
    if (N <= 32) {
        if ((1LL << (N - 1)) <= M) {
            cout << ((1LL << N) - 1) << '\n';
            return 0;
        }
    }
    V<ll> A = {M};
    ll cm = M;
    while (cm != 1) {
        cm = (cm + 1) / 2;
        A.push_back(cm);
    }
    reverse(A.begin(), A.end());
    show(A);
    if (A.size() >= N) {
        ll ans = 0;
        rep(i, N) ans += A[i];
        cout << ans << '\n';
    } else {
        ll ans = 0;
        for (auto &a : A) ans += a;
        N -= A.size();
        ans += N;
        cout << ans << '\n';
    }
    return 0;
}