fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }
fun main(args:Array<String>){
  var s = next()
  var n = s.length
  var ans = 100000000
  for(i in 0..n-3){
    var str = s.substring(i,i+3)
    var tmp = str.toInt() - 753
    if(tmp<0) tmp *= -1
    ans = if(ans<tmp) ans else tmp
  }
  println(ans)
}
