def main(): A, B, S = map(int, input().split()) if abs(S-A) <= abs(S-B): print(abs(S-A) + S) elif A == 0: print(abs(S-B) + (B-1) + 2) else: print(abs(S-B) + min(abs(B-A), abs(B-1)) + A) if __name__ == '__main__': main()