a,b,c = map(int,input().split()) cost_1 = abs(a-c) for i in range(b,0,-1): if max(a,c) > i > min(a,c): tmp = i break ans = min(cost_1,tmp) print(ans)