fun main(args : Array<String>) {
    val S = readLine()!!
    val trg = 753
    val lastIndex = S.length - 1

    val min = (0..lastIndex - 2).map {
        val from = it
        val to = it + 3
        Math.abs(Integer.parseInt(S.subSequence(from, to).toString()) - trg)
    }.min()

    println(min)
}