minDiffFrom753 :: String -> Int
minDiffFrom753 ('7':'5':'3':xs) = 0
minDiffFrom753 target@(x1:x2:x3:xs)
  | null xs   = diff
  | otherwise = min diff $ minDiffFrom753 $ tail target
  where extracted = read [x1,x2,x3]
        diff      = abs $ extracted - 753

main :: IO ()
main = do
  target <- getLine
  print $ minDiffFrom753 target