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