A, B, S = map(int, input().split()) dA, dB = abs(S - A), abs(S - B) if S == 1 or dA <= dB: print(dA + S) exit() if A == 0: print(dB + S + 1) else: print(dB + abs(B - A) + A)