object Main extends App {
  val in = io.Source.stdin.getLines.toIndexedSeq.head
  val len = in.length
  val ret = (0 to len-3).foldLeft(Int.MaxValue){ (a,i) =>
    val num:Int = ("" + in(i) + in(i+1) + in(i+2)).toInt
    val diff = Math.abs(num - 753)
    Math.min(a, diff)
  }
  println(ret)
}
