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