fun main(args: Array<String>) {
    abc114b()
}

fun abc114b() {
    val s = readLine()!!

    val absTo753 = (0..(s.length - 3))
        .map { Math.abs(s.substring(it..it + 2).toInt() - 753) }

    println(absTo753.min())
}
