def main(): a, b, s = map(int, input().split()) if s == 1: print(abs(a - 1) + 1) elif abs(a - s) <= abs(b - s): print(abs(a - s) + s) else: ans1 = abs(b - s) + abs(s - a) + a ans2 = abs(b - s) + abs(s - 1) + abs(a - 1) + 1 print(min(ans1, ans2)) if __name__ == '__main__': main()