object Main extends App {
  import io.StdIn._
  val line = readLine()
  val calculatedNumbers = ( 0 to line.length - 3) map { index =>
    (753 - line.substring(index, index + 3).toInt).abs
  }
  println(calculatedNumbers.min)
}