import java.util.Scanner

object Main {
  def main(args: Array[String]):Unit = {
    val sc = new Scanner(System.in)

    val S = sc.next

    val numList = (0 to S.length - 3).map{i =>
      S.substring(i,i + 3).toInt
    }

    val min = numList.map(n => Math.abs(n - 753)).min

    println(min)



  }

}
