a, b, s = map(int, input().split()) if abs(s - a) <= abs(s - b): print(abs(s - a) + s) else: print(abs(s - b) + s + abs(a - 1))