#two elevators def ab(n): if n<0: n*=-1 return n A,B,S=(int(i) for i in input().split()) da=ab(A-S) db=ab(B-S) if S==1: p=ab(S-1)+1 elif A==0: p=S+1 elif da<=db: p=da+S elif A<=S: p=db+S elif S-1