a, b, s = map(int, input().split()) step = 0 if s == 1 or abs(s - a) <= abs(s - b): # A → goal step += abs(s - a) + s else: # B → A → goal step += abs(s - b) + abs(s - a) if a == 0: step += 1 print(step)