object Main extends App {
  
  val sc = new java.util.Scanner(System.in) 
  val S = sc.next().toList.map(_.toString)
  var ans = 999
  for(i <- 0 to (S.length - 3)) {
    val diff = (753 - (S(i) + S(i+1) + S(i+2)).toInt).abs
    ans = ans.min(diff)
  }
  println(ans) 
}