import scala.io.StdIn import scala.math.min object Main extends App { val (l, r, m) = StdIn.readLine().split(' ') match { case Array(l, r, m) => (l.toInt, r.toInt, m.toInt) } println(min(m, r - (l - 1))) }