threeNums :: String -> [Int]
threeNums s@(x:xs)
  | length s >= 3 = (read $ take 3 s) : threeNums xs
  | otherwise = []

nearest :: [Int] -> Int
nearest = foldr1 min . map (abs . (753 - ))

calc :: String -> Int
calc = nearest . threeNums

main = do
  line <- getLine
  print $ calc line
