solve :: Int -> [Int] -> Int
solve diff [x2, x3] = diff
solve diff (x1:x2:x3:xs) = solve diff' (x2:x3:xs)
  where x = x1 * 100 + x2 * 10 + x3
        diff' = if abs (x - 753) < diff
                then abs (x - 753)
                else diff

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