#include <bits/stdc++.h>
using namespace std;
const long long OO = (long long)1e15;
using namespace std;
long long Pow(long long B, long long P) {
  long long R = 1;
  while (P > 0) {
    if (P & 1) R = (R * B);
    P /= 2;
    B = (B * B);
  }
  return R;
}
long long GCD(long long a, long long b) {
  while (b) {
    b ^= a ^= b ^= a %= b;
  }
  return a;
}
long long LCM(long long a, long long b) { return (a / GCD(a, b) * b); }
long long BigMod(long long B, long long P, long long M) {
  long long R = 1;
  while (P > 0) {
    if (P & 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return (long long)R;
}
long long cnt(long long h, long long x, char dir) {
  if (h == 0) return 0;
  if (x > (1LL << (h - 1)) && dir == 'l')
    return (1LL << h) + cnt(h - 1, x - (1LL << (h - 1)), 'l');
  else if (x > (1LL << (h - 1)))
    return 1 + cnt(h - 1, x - (1LL << (h - 1)), 'l');
  else if (x <= (1LL << (h - 1)) && dir == 'r')
    return (1LL << h) + cnt(h - 1, x, 'r');
  else
    return 1 + cnt(h - 1, x, 'r');
}
int main() {
  ios::sync_with_stdio(0);
  long long h, n;
  cin >> h >> n;
  cout << cnt(h, n, 'l');
  return 0;
}
