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