#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
const int MAX = 1e9 + 5;
int i, j, k, n, m, ans, h;
long long leaf;
long long solve(long long x, long long y, int depth, bool d) {
  long long mid = x + y >> 1;
  if (depth == 0) return 0;
  if (leaf > mid) {
    if (d == 1) return solve(mid + 1, y, depth - 1, 0) + 1;
    return solve(mid + 1, y, depth - 1, d) + (1ll << depth);
  }
  if (d == 0) return solve(x, mid, depth - 1, 1) + 1;
  return solve(x, mid, depth - 1, d) + (1ll << depth);
}
int main() {
  scanf("%d %lld", &h, &leaf);
  cout << solve(1, 1LL << h, h, 0);
  return 0;
}
