n,x = gets.split.map(&:to_i)

$a,$q = [1],[1]
n.times{|i|
  $a << $a[i]*2+3
  $q << $q[i]*2+1
}

def f(n,x)
  if n==0
    return (x<=0)? 0 : 1
  elsif x <= 1+$a[n-1]
    return f(n-1,x-1)
  else
    return $q[n-1]+1+f(n-1,x-2-$a[n-1])
  end
end

p f(n,x)