#include <bits/stdc++.h>
using namespace std;
long long int pw(long long int b, long long int p) {
  if (!p) return 1;
  long long int sq = pw(b, p / 2);
  sq *= sq;
  if (p % 2) sq *= b;
  return sq;
}
int main() {
  bool l, test1, test2, test3;
  long long int h, n, ans = 0, x, y, z;
  cin >> h >> n;
  long long int r[h + 1];
  for (int i = 0; i <= h; i++) r[i] = pw(2, i);
  l = true;
  for (int i = h; i >= 0; i--) {
    if (l && n > (r[i] / 2)) {
      ans += r[i];
      n -= r[i] / 2;
      continue;
    }
    if (l && n <= (r[i] / 2)) {
      l = 0;
      ans++;
      continue;
    }
    if (!l && n <= (r[i] / 2)) {
      ans += r[i];
      continue;
    }
    if (!l && n > (r[i] / 2)) {
      l = 1;
      ans++;
      n -= r[i] / 2;
      continue;
    }
  }
  cout << ans - 1;
}
