#include <bits/stdc++.h>
using namespace std;
unsigned long long pow(int x) {
  unsigned long long Ret = 1;
  for (int i = 1; i <= x; i++) Ret *= 2;
  return Ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  int h;
  unsigned long long l, r, n;
  cin >> h >> n;
  r = pow(h);
  unsigned long long nodes = 0;
  bool p = 0;
  l = 1;
  while (l != r) {
    unsigned long long mid = (l + r) / 2;
    if (n <= mid) {
      if (p == 0) {
        nodes++;
        p = !p;
      } else {
        nodes += pow(h);
      }
      r = mid;
    } else {
      if (p == 0) {
        nodes += pow(h);
      } else {
        nodes++;
        p = !p;
      }
      l = mid + 1;
    }
    h--;
  }
  cout << nodes;
}
