#include <bits/stdc++.h>
using namespace std;
int m, h, tot = 0;
long long n, mid;
int main() {
  int i = 0, j = 0;
  long long ans = 0;
  scanf("%d %I64d", &h, &n);
  int root = 1, odd = 1, even = 2;
  while (h > 0) {
    mid = (long long)1 << (h - 1);
    if (root == odd) {
      if (n > mid) {
        ans += (mid * 2);
        h--;
        n = n - mid;
      } else {
        root = even;
        ans += 1;
        h--;
      }
      continue;
    }
    if (root == even) {
      if (n > mid) {
        root = odd;
        ans++;
        h--;
        n = n - mid;
      } else {
        ans += (mid * 2);
        h--;
      }
    }
  }
  printf("%I64d", ans);
  return 0;
}
