#include <bits/stdc++.h>
using namespace std;
int main() {
  long long cnt = 0;
  int H;
  scanf("%d ", &H);
  ;
  long long N;
  cin >> N;
  N--;
  long long n = 0;
  int d = 0;
  for (int h = (0); h < (H); h++) {
    long long msk = ((1LL) << (long long)(H - h - 1));
    if (N & msk) {
      if (d & 1)
        cnt++;
      else {
        cnt += msk * 2LL;
        d++;
      }
    } else {
      if (d & 1) {
        cnt += msk * 2LL;
        d++;
      } else
        cnt++;
    }
    d++;
  }
  cout << cnt << endl;
  return 0;
}
