# coding:utf-8 A, B, S = map(int, input().split()) ans = 0 if abs(A-S) <= abs(B-S): # print('A') ans = abs(A-S)+S # ここからB elif S > A: # print('B') if A == 0: ans += 1 A = 1 ans += abs(B-S)+abs(A-S) + A else: # print('else') ans = abs(B-S)+min(A+(S-1), abs(A-S)+A) print(ans) # 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)