#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from functools import lru_cache\n"
"@lru_cache(maxsize=None)\n"
"def b(n):\n"
"    if n<1:return 1\n"
"    return b(n-1)*2+3\n"
"@lru_cache(maxsize=None)\n"
"def p(n):\n"
"    if n<1:return 1\n"
"    return p(n-1)*2+1\n"
"def solve(n,x):\n"
"    if n<1:return int(x>0)\n"
"    if x-2<b(n-1):return(solve(n-1,x-1))\n"
"    return p(n-1)+solve(n-1,x-b(n-1)-2)+1\n"
"print(solve(*map(int,input().split())))\n"
"\"";
  system(s);
  return 0;
}            