object Main extends App{
  import scala.io.StdIn.readLine
  
  val s = readLine.split("").map(_.toInt)
  val xs = (0 to s.length - 3).map(x => 100 * s(x) + 10 * s(x + 1) + s(x + 2))
  
  println(xs.map(a => math.abs(753 - a)).min.toString)

}
