n,$x = gets.split.map(&:to_i)
$p,$b = 2.times.map{Array.new(51,0)}
$p[0] = 1
50.times do |i|
    $p[i+1] = $p[i]*2+1
    $b[i+1] = $b[i]*2+2
end

$ret = 0
def calc_p(d)
    return $ret if $x == 0
    if $x >= $p[d]+$b[d]
        $x -= $p[d]+$b[d]
        $ret += $p[d]
    else
        $x -= 1
        calc_p(d-1)
        return $ret if $x == 0
        $x -= 1
        $ret += 1
        calc_p(d-1)
        return $ret if $x == 0
        $x -= 1
    end
end
calc_p(n)
puts $ret