fun main(args: Array<String>) {
    val s = readLine() ?: return
    val target = 753
    0.until(s.length - 2).map {
        Math.abs(target - "${s[it]}${s[it + 1]}${s[it + 2]}".toInt())
    }.min()?.let {
        println(it.toString())
    }
}