main :: IO ()
main = do
  s <- getLine
  putStrLn . show . solve $ s

solve :: String -> Int
solve = solve2. solve1

solve1 :: String -> [Int]
solve1 [] = []
solve1 (_:[]) = []
solve1 (_:_:[]) = []
solve1 (x:y:z:xs) = (read (x:y:z:[])) : solve1 (y:z:xs)

solve2 :: [Int] -> Int
solve2 xs = minimum $ (map (\x -> abs (x - 753))) xs
