#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int abs(int a) {
  if (a < 0) return -a;
  return a;
}
long long h, n, sol = 0;
int main() {
  int d = 0;
  cin >> h >> n;
  long long l = 0, r = 1 << h;
  r--, n--;
  for (int i = h; i > 0; i--) {
    long long aux = 1;
    aux <<= (i - 1);
    if (aux + l <= n) {
      l += aux;
      aux = 1;
      aux <<= i;
      if (d == 0)
        sol += aux;
      else
        sol++;
      d = 0;
    } else {
      r -= aux;
      aux = 1;
      aux <<= i;
      if (d == 1)
        sol += aux;
      else
        sol++;
      d = 1;
    }
  }
  cout << sol << endl;
}
