import Data.List

main :: IO ()
main = do
  s <- map read . map return <$> getLine
  print $ solve s

solve :: [Int] -> Int
solve xs = minimum $ map (abs . subtract 753) $ zipWith3 (\x y z -> 100 * x + 10 * y + z) xs ys zs
  where
    ys = tail xs
    zs = tail ys