import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()

    println(abc114b(s))
}

private fun abc114b(s: String): Int {
  val ansList = mutableListOf<Int>()

  var start = 0
  var end = start + 3
  while (end <= s.length) {
    val sub = s.subSequence(start, end)
    val si = sub.toString().toInt()
    val diff = Math.abs(si - 753)
    ansList.add(diff)

    start++
    end++
  }

  return ansList.min()!!
}
