#include <bits/stdc++.h>
using namespace std;
struct flist {
  int pos;
  int val;
};
bool acomp(flist a, flist b) { return (a.val < b.val); }
long long floorSqrt(long long x) {
  if (x == 0 || x == 1) return x;
  long long start = 1, end = x, ans;
  while (start <= end) {
    int mid = (start + end) / 2;
    if (mid * mid == x) return mid;
    if (mid * mid < x) {
      start = mid + 1;
      ans = mid;
    } else
      end = mid - 1;
  }
  return ans;
}
long long poww[64];
long long h, n;
using namespace std;
long long ans = 0;
void recur(long long left, long long right, int mov, int height) {
  if (h - height < 0) {
    return;
  }
  if (mov == 0) {
    if ((left + poww[h - height] - 1) >= n) {
      ans += 1;
      recur(left, left + poww[h - height] - 1, 1 - mov, height + 1);
    } else {
      ans += poww[h - height + 1];
      recur(left + poww[h - height], right, mov, height + 1);
    }
  } else {
    if (n >= left + poww[h - height]) {
      ans += 1;
      recur(left + poww[h - height], right, 1 - mov, height + 1);
    } else {
      ans += poww[h - height + 1];
      recur(left, left + poww[h - height] - 1, mov, height + 1);
    }
  }
}
int main() {
  for (int i = 0; i < 63; i++) {
    poww[i] = (long long)(1) << i;
  }
  cin >> h >> n;
  ;
  recur(poww[0], poww[h], 0, 1);
  printf("%lld\n", ans);
}
