object Main{
  def main(args:Array[String]):Unit={
    var str = readLine
    var len = str.length
    var res = scala.Int.MaxValue
    for(i <- 0 until len-3){
      var tmp = str.substring(i,i+3).toInt
      var diff = tmp-753
      res = scala.math.abs(res,diff.toInt)
    }
    println(res)
  }
}