{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}

main :: IO ()
main = do
  s <- getLine
  print $ solve s

solve :: String -> Int
solve s = minimum . map (abs . (subtract 753) . read) $ windows 3 s

windows :: Int -> [a] -> [[a]]
windows n xs = go [] xs
  where
    go acc xs
      | length ys /= n = acc
      | otherwise      = go (ys:acc) (tail xs)
      where
        ys = take n xs
