import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >>= print . solve 

solve :: String -> Int
solve = minimum . count
    where
        count s@(_ : _ : _ : _) = abs (753 - v) : count (tail s)
            where
                v = read $ take 3 s
        count _ = []

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine