#include 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 using V = vector; int main() { ios::sync_with_stdio(false); cin.tie(0); ll N, M; cin >> N >> M; V 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; }