#include <bits/stdc++.h>
using namespace std;
unsigned long long n, H;
unsigned long long bound[60];
unsigned long long cnt(unsigned long long p, unsigned long long h,
                       unsigned long long n) {
  if (h == 1) {
    if (p == 0 && n == 1) return 1;
    if (p == 1 && n == 2) return 1;
    return 2;
  }
  unsigned long long res = 1;
  if (n > bound[h - 1] && p == 0 || n <= bound[h - 1] && p == 1)
    res += 2 * bound[h - 1] - 1;
  if (n > bound[h - 1])
    res += cnt(0, h - 1, n - bound[h - 1]);
  else
    res += cnt(1, h - 1, n);
  return res;
}
int main() {
  cin >> H >> n;
  bound[0] = 1;
  for (unsigned long long i = 0; i < H; ++i) bound[i + 1] = 2 * bound[i];
  cout << cnt(0, H, n);
  return 0;
}
