import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  s <-getLine
  print $minimum $map (abs .(753-) .(read::String->Int)) $subString 3 s

subString _ [] = []
subString n s@(x:xs)
  |n<=length s = take n s : subString n xs
  |otherwise   = []