class Yukicoder def initialize x, y, d = gets.chomp.split(' ').map(&:to_i) puts [0, 1 + [d, x].min - (d - [d, y].min)].max end end Yukicoder.new