#include <bits/stdc++.h>
using namespace std;
const string problemName = "";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
const int INF = (1LL << 31) - 1;
const long long int LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int MOD = (int)(1e9) + 7;
const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int KMAX = 100000 + 5;
const int PMAX = 100000 + 5;
const int LMAX = 100000 + 5;
const int VMAX = 100000 + 5;
long long int N, H, sol;
void dei(long long int lo, long long int hi, long long int dir) {
  if (lo == hi) return;
  long long int mi = (lo + hi) / 2;
  if (N <= mi && dir == 0) {
    sol++;
    dei(lo, mi, 1 - dir);
    return;
  }
  if (N <= mi && dir == 1) {
    sol += hi - lo + 1;
    dei(lo, mi, dir);
    return;
  }
  if (N > mi && dir == 0) {
    sol += hi - lo + 1;
    dei(mi + 1, hi, dir);
    return;
  }
  if (N > mi && dir == 1) {
    sol++;
    dei(mi + 1, hi, 1 - dir);
    return;
  }
}
int main() {
  scanf("%lld%lld", &H, &N);
  dei(1, (1LL << H), 0);
  printf("%lld\n", sol);
  return 0;
}
