object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var s = sc.next()
  var list:Array[Char] = Array.fill(s.length)(' ')
  var ans_list:Array[Int] = Array.fill(s.length - 2)(0)
  for (i <- 0 until s.length){
    list(i) = s(i)
  }
  for (i <- 0 until s.length - 2){
    ans_list(i) = (753 - (list(i).asDigit * 100 + list(i + 1).asDigit * 10 + list(i + 2).asDigit)).abs
  }
  println(ans_list.min)
}
