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