import java.util.*
import java.math.*;
fun main(args: Array<String>) {

    //val N = readLine()!!.split("").map{it.toInt()}
    val S = readLine()!!
    //val K = readLine()!!.split(" ").map{it.toInt()}[0]
    var ans = 0
    var min = 1000;
    for (i in 0 until S.length-2) {
        var tmp = S.substring(i..i+2).toInt()
        var t = Math.abs(tmp-753)
        if (min < t) continue
        min = t
    }

    println(min)
}
