(defn inner-func [S]
  (loop [s S r nil]
    (if (< (count s) 3)
      r
      (recur
        (rest s)
        (cons (->> s
                (take 3)
                (apply str)
                (Integer/parseInt))
          r)))))

(defn func [S]
  (->> (inner-func S)
    (map #(Math/abs (- % 753)))
    (apply min)))

(->> (read-line)
  func
  println)