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

def burger(m)
	return 0 if m==0
	return [1,burger(m-1),0,burger(m-1),1]
end

the_burger = burger(n).flatten.reverse!
count=0
for i in 0..x-1
	count += 1 if the_burger[i] == 0
end
puts count