import scala.io.{StdIn => in}

object Main extends App {
  val s = in.readLine

  var ans = 1000
  for(i <- 0 until s.size-2) {
    val s2 = s.drop(i).take(3)
    // println(s2)
    ans = math.min(ans, (753 - s2.toInt).abs)
  }

  println(ans)
}