object Main extends App {
    val s = readLine
    val x = for (i <- 0 to s.length - 3) yield {
        s.slice(i, i + 3).toInt
    }
    println(x.map(n => Math.abs(n - 753)).reduce(Math.min(_, _)))
}