A, B, S = gets.split.map(&:to_i) ans = if (A - S).abs <= (B - S).abs or S == 1 (A - S).abs + S elsif A == 0 (B - S).abs + S + 1 else (B - S).abs + [(A - S).abs + A, S - 1 + A].min end puts ans