#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18, MOD = 1e9 + 7, MAXN = 18, MAXM = 1e5 + 1;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long bin_pow(long long a, long long n) {
  if (n == 0) return 1;
  long long b = bin_pow(a, n / 2);
  if (n & 1)
    return b * b * a;
  else
    return b * b;
}
long long rec(long long v, long long tl, long long tr, long long c, bool l,
              long long x) {
  if (tl == tr) {
    return 0;
  }
  long long tm = (tl + tr) / 2;
  long long res = 0;
  if (x <= tm) {
    res = rec(v * 2, tl, tm, c - 1, 0, x);
    if (!l) {
      res += bin_pow(2, c) - 1;
    }
  } else {
    res = rec(v * 2 + 1, tm + 1, tr, c - 1, 1, x);
    if (l) res += bin_pow(2, c) - 1;
  }
  return res + 1;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long h, n;
  cin >> h >> n;
  cout << rec(1, 1, bin_pow(2, h), h, 1, n);
}
