nx = gets.chomp!.split(" ")
nx = nx.map{|item| item=item.to_i}

hamburgers = Array.new(nx[0],[])
hamburgers[0] = [false]#bun is true, patty is false
for i in 1..nx[0]
	hamburgers[i-2] = []
	hamburgers[i] = [true] + hamburgers[i-1] + [false] + hamburgers[i-1] + [true]
	if hamburgers[i].size>nx[1] then
		hamburgers[i] = hamburgers[i].take(nx[1])
	end
end

answer = hamburgers[nx[0]].take(nx[1]).count(false)

puts answer