fun main(args: Array<String>) {

    val s = readLine()!!
    val l = 753

    var min = Integer.MAX_VALUE
    for (i in 0 until s.length - 2) {
        min = Math.min(min, Math.abs(l - s.slice(i..i + 2).toString().toInt()))
    }
    println(min)
}