import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines A,B,S = map(int,read().split()) def f(A,B,S): if abs(A-S) <= abs(B-S) or S == 1: return abs(A-S) + abs(S) x = abs(B-S) + abs(S-1) + abs(A-1) + 1 if A == 0: return x y = abs(B-S) + abs(S-A) + abs(A) return min(x,y) # f(5,10,7), f(10,50,30), f(0,1,1) answer = f(A,B,S) print(answer)