#include <bits/stdc++.h>
using namespace std;
int n;
long long h;
long long c = 0;
long long base = 1;
void solve(long long lo, long long hi, int t, bool izq) {
  long long mid = (lo + hi) / 2;
  if (t == 0) return;
  if (izq && h > mid) {
    c += base << t;
    solve(mid + 1, hi, t - 1, true);
  } else if (izq && h <= mid) {
    ++c;
    solve(lo, mid, t - 1, false);
  } else if (!izq && h <= mid) {
    c += base << t;
    solve(lo, mid, t - 1, false);
  } else if (!izq && h > mid) {
    ++c;
    solve(mid + 1, hi, t - 1, true);
  }
}
int main() {
  cin >> n >> h;
  long long low = 1, high = base << (n);
  bool izq = true;
  solve(low, high, n, izq);
  cout << c << endl;
  return 0;
}
