#include <bits/stdc++.h>
using namespace std;
long long ans(int h, long long n) {
  if (h == 0) return 0;
  if (n <= (1ll << (h - 1))) {
    return 1 + ans(h - 1, (1ll << (h - 1)) - n + 1);
  } else {
    return (1ll << (h)) + ans(h - 1, n - (1ll << (h - 1)));
  }
}
int main() {
  int h;
  long long n;
  cin >> h >> n;
  cout << ans(h, n);
}
