#include <bits/stdc++.h>
long long e, h, st, c1, c2, c3, s, hn;
long long power(long long k) {
  if (k == 1) return (long long)2;
  long long s = power(k / 2);
  if (k % 2 == 1)
    return s * s * 2;
  else
    return s * s;
}
int main() {
  scanf("%I64d %I64d", &h, &e);
  c1 = 1;
  c2 = power(h);
  while (c1 != c2) {
    c3 = (c1 + c2) / 2;
    if (st == 0) {
      if (e <= c3) {
        s++;
        st = 1;
        c2 = c3;
      } else {
        s += power(h);
        c1 = c3 + 1;
      }
    } else {
      if (e <= c3) {
        s += power(h);
        c2 = c3;
      } else {
        s++;
        st = 0;
        c1 = c3 + 1;
      }
    }
    h--;
  }
  printf("%I64d\n", s);
  return 0;
}
