#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-9;
const int INF = 1e9 + 7;
const long long LINF = 8e18 + 7;
const int N = 57;
long long s[N];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  s[0] = 1;
  for (int i = 1; i < N; ++i) {
    s[i] = s[i - 1] + (1ll << i);
  }
  long long h, n;
  cin >> h >> n;
  long long l = 1, r = (1ll << h), ans = 0;
  int go = 0;
  while (l < r) {
    long long m = l + (r - l) / 2;
    if (!go) {
      if (n <= m) {
        r = m;
        ans++;
        go = 1;
      } else {
        l = m + 1;
        ans += s[h - 1] + 1;
      }
    } else {
      if (n <= m) {
        r = m;
        ans += s[h - 1] + 1;
      } else {
        l = m + 1;
        ans++;
        go = 0;
      }
    }
    h--;
  }
  cout << ans << endl;
}
