import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val S = sc.nextLine()
  println { (1 to S.length-2).foldLeft(800)((z:Int,i:Int) => math.min(math.abs(S.substring(i-1,i+2).toInt-753),z)) }
  println { "12345".substring(0,3).toInt - 123 }
}
