a,b,s = gets.split.map(&:to_i) if s == 1 p (a - s).abs + 1 elsif (a - s).abs <= (b - s).abs p (a - s).abs + s else p (b - s).abs + s - 1 + (a - 1).abs + 1 end