A, B, S = map(int, input().split()) min_total = float('inf') if S == 1: # Case 1: Press down button (only A can come) total_case1 = abs(S - A) + S min_total = min(min_total, total_case1) # Case 2: Press up button (normal condition) a_dist = abs(S - A) b_dist = abs(S - B) if a_dist <= b_dist: total_case2 = a_dist + S min_total = min(min_total, total_case2) else: a_dist = abs(S - A) b_dist = abs(S - B) if a_dist <= b_dist: total = a_dist + S min_total = total print(min_total)