import scala.math._

object Main extends App {
 val in = readLine.split("").tail
 val list = for(i <- (0 to in.length - 3)) yield {
   val num = in(i)+in(i+1)+in(i+2)
   abs(num.toInt - 753)
 }
  println(list.min)
}