import java.lang.Math

fun main(args: Array<String>) {
    val s = readLine()
    var diff = Int.MAX_VALUE
    for (i in 0..(s!!.length - 3)) {
        val chunk = s.substring(i, i + 3).toInt()
        diff = Math.min(diff, Math.abs(753 - chunk))
    }
    println(diff)
}
