fun main(args :Array<String>) {
    val s = readLine()!!
    val ss = s.map { it.toInt() - '0'.toInt() }.toIntArray()
    var ans = Int.MAX_VALUE
    for (i in 0 until (ss.size - 2)) {
        val tmp = ss[i] * 100 + ss[i + 1] * 10 + ss[i + 2]
        ans = Math.min(ans, Math.abs(753 - tmp))
    }

    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
