#include <bits/stdc++.h>
using namespace std;
long long solve(long long n, int h, bool f) {
  if (!h) return 0;
  long long ret = 1;
  long long total = (1ll << h) - 1, leaf = 1ll << (h - 1);
  if (f) {
    if (leaf < n) {
      ret += total;
      ret += solve(n - leaf, h - 1, f);
    } else
      ret += solve(n, h - 1, !f);
  } else {
    if (leaf < n) {
      ret += solve(n - leaf, h - 1, !f);
    } else {
      ret += total;
      ret += solve(n, h - 1, f);
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, h;
  cin >> h >> n;
  cout << solve(n, h, 1) << endl;
  return 0;
}
