A, B, S = map(int, input().split()) option1 = abs(A - S) + S if S == 1: print(option1) else: option2 = abs(B - S) + abs(S - A) + A print(min(option1, option2))