#include <bits/stdc++.h>
using namespace std;
int main() {
  long long h, n;
  cin >> h >> n;
  long long l = 1, r = (1LL << h), ret = 0, cur = 0, dir = 0;
  while (cur < h) {
    long long size = (1LL << (h - cur)), mid = (l + r) / 2;
    if (dir == 0) {
      if (n <= mid)
        ++ret, r = mid, dir = 1;
      else
        ret += size, l = mid + 1;
    } else {
      if (n <= mid)
        ret += size, r = mid;
      else
        ++ret, l = mid + 1, dir = 0;
    }
    ++cur;
  }
  cout << ret << endl;
}
