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