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