#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  bool ok = false;
  if (N <= 30){
    if (M > (1 << (N - 1))){
      ok = true;
    }
  }
  if (ok){
    long long ans = 0;
    for (int i = 0; i < N; i++){
      ans += 1 << i;
    }
    cout << ans << endl;
  } else {
    long long ans = 0;
    while (true){
      if (M == 1){
        ans += N;
        break;
      } else {
        ans += M;
        M = (M + 1) / 2;
        N--;
      }
    }
    cout << ans << endl;
  }
}