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