local a, b, s = io.read("*n", "*n", "*n") if(s == 1) then print(math.abs(a - 1) + 1) else if(math.abs(a - s) <= math.abs(b - s)) then print(math.abs(a - s) + s) else if(a == 0) then print(math.abs(b - s) + math.abs(s - 1) + 2) else print(math.abs(b - s) + math.abs(a - s) + a) end end end