#include <bits/stdc++.h>
using namespace std;
long long arr[52];
int main() {
  long long i, j, k, l, n, h;
  cin >> h;
  cin >> n;
  arr[0] = 1;
  for (int i = 1; i <= 50; i++) {
    arr[i] = arr[i - 1] * 2;
  }
  char c = 'L';
  j = 0;
  k = 0;
  l = 0;
  while (k < h) {
    if (c == 'L') {
      if (j + arr[h - k - 1] < n) {
        j += arr[h - k - 1];
        l += arr[h - k];
        k++;
        c = 'L';
      } else {
        k++;
        l++;
        c = 'R';
      }
    } else {
      if (j + arr[h - k - 1] < n) {
        j += arr[h - k - 1];
        l++;
        k++;
        c = 'L';
      } else {
        l += arr[h - k];
        k++;
        c = 'R';
      }
    }
  }
  cout << l << "\n";
}
