object Main extends App {
	val S = scala.io.StdIn.readLine
	var ans = List[Int]()
	for(i<-0 until S.size-2){
		val a = S(i).toInt - 48
		val b = S(i+1).toInt - 48
		val c = S(i+2).toInt - 48
		ans ::= a*100 + b*10 + c 
	}
//	println(ans.mkString(" "))
	println(ans.map{z => (z - 753).abs}.min)

}
