#include <bits/stdc++.h>
int main() {
  long long h, n;
  scanf("%lld%lld", &n, &h);
  long long ans = 0;
  while (n > 0) {
    if (h > 1LL << n - 1) {
      h -= 1LL << n - 1;
      ans += 1LL << n;
    } else {
      h = (1LL << n - 1) - h + 1;
      ans += 1;
    }
    n--;
  }
  printf("%lld\n", ans);
  return 0;
}
