object Main extends App {
  val S = io.StdIn.readLine()
  var min = 1000
  var sub = 0
  for(x <- 1 to S.length-3){
    sub = 753 - S.substring(x, x+3).toInt
    if(sub < 0 && -sub < min){
      min = -sub
    }else if(sub >= 0 && sub < min){
      min = sub
    }
  }
  println(min)
}