#include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint32_t N, M; cin >> N >> M; uint64_t ans = 0; if (N <= 30 && M >= (1u << N)) cout << (1u << (N + 1)) << '\n'; else { for (; N != 0 && M != 1; --N, M = (M + 1) >> 1) ans += M; cout << ans + N << '\n'; } return 0; }