import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val s = next()

    var min = 753

    for (i in 0..s.length-3) {
        val diff = Math.abs(s.slice(i..i+2).toInt() - 753)
        if (diff < min) min = diff
    }

    println(min)
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}