#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int h, n;
  cin >> h >> n;
  long long int L = 1, R = 1;
  while (h > 0) {
    R = R << 1;
    h--;
  }
  bool f = 0;
  long long int STEPS = 0;
  while (L < R) {
    long long int tot = (R - L + 1);
    long long int mid = L + tot / 2 - 1;
    if (f == 0) {
      if (n > mid) {
        STEPS += tot;
        L = mid + 1;
        f = 0;
      } else {
        STEPS++;
        R = mid;
        f = 1;
      }
    } else {
      if (n > mid) {
        STEPS++;
        L = mid + 1;
        f = 0;
      } else {
        STEPS += tot;
        R = mid;
        f = 1;
      }
    }
  }
  cout << STEPS << endl;
  return 0;
}
