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