io = STDIN
n,x=io.gets.split.map(&:to_i)
$size={0=>1}
def size(n)
  return $size[n] if $size.has_key?(n)
  $size[n]=size(n-1)*2+3
end
def half_h(size)
  (size-3)/2
end
$f={}
def f(n,k)
  return 1 if n==0
  return $f[[n,k]] if $f.has_key?([n,k])
  h=size(n-1)+2
  return 0 if k==1
  if k<h
    rtn=f(n-1,k-1)
  elsif k==h
    rtn=f(n-1,h-2)+1
  else
    rtn=f(n-1,h-2)+1+f(n-1,k-h)
  end
  $f[[n,k]]=rtn
end
p f(n,x)
