import java.lang.Math.abs

fun main(args: Array<String>){
    val s = readLine()!!
    var ans = 1000
    (2 until s.length).map { i ->
        val x = (s[i - 2].toString() + s[i - 1] + s[i]).toInt()
        ans = if(abs(753 - x) < ans) abs(753 - x) else ans
    }
    println(ans)
}

