import scala.io.StdIn._
import scala.math.abs

object Main extends App {
  val s = readLine()

  require(4 <= s.length && s.length <= 10)

  var i    = 0
  var list = Seq.empty[Int]
  while (i < s.length - 2) {
    val j = s.substring(i).take(3).toInt
    list = list.appended(j)
    i = i + 1
  }
  println(abs(list.minBy(i => abs(i - 753)) - 753))
}
