# frozen_string_literal: true def solve D > X + Y ? 0 : [X, D].min + [Y, D].min - D + 1 end X, Y, D = gets.split.map(&:to_i) puts solve