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