import sequtils,strutils var A,B,S : int (A, B, S) = stdin.readline.split.map(parseInt) if abs(A - S) <= abs(B - S) or S == 1: echo abs(A - S) + S else: if A > 0: echo min(abs(B - S) + S + abs(A - 1), abs(B - S) + abs(S - A) + A) else: echo abs(B - S) + S + 1