class Calc0131 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @x, @y, @d = args.shift.map(&:to_i) end def run if @d > @x + @y 0 else c = @d + 1 c -= (@d - @x) if @d > @x c -= (@d - @y) if @d > @y c end end end puts Calc0131.new(STDIN.readlines).run if __FILE__ == $0