local a, b, c = io.read("*n", "*n", "*n") for dst = 30, 0, -1 do local rem = c if dst <= b + rem then rem = rem - math.max(0, dst - b) if dst <= a + rem then print(dst) break end end end