#include <bits/stdc++.h>
using namespace std;
long long power(int x) {
  long long ret = 1;
  for (int i = 0; i < x; i++) ret *= 2LL;
  return ret;
}
int main() {
  int h;
  long long n;
  cin >> h >> n;
  long long res = 0;
  int height = h;
  bool com = 0;
  while (height) {
    res++;
    long long range = power(height);
    if (n <= range / 2) {
      if (com) res += power(height) - 1;
      height--;
      com = 1;
    } else {
      if (!com) res += power(height) - 1;
      height--;
      com = 0;
      n -= range / 2;
    }
  }
  cout << res << "\n";
}
