A, B, S = map(int, raw_input().split()) toA = abs(S-A) toB = abs(S-B) if toA <= toB: ans = toA + S else: ans = toB + toA + S print ans