import scala.io.StdIn.readLine

object Main extends App {

  val ins: List[Int] = readLine.toList.map(_.toString.toInt)

  val nums = ins.sliding(3).map { ns =>
    100 * ns(0) + 10 * ns(1) + ns(2)
  }.toList

  val nearest = nums.map(n => math.abs(753 - n)).sorted.head

  println(nearest)

}