f :: String -> Int
f [x',y',z'] = abs $ 753 - (100*(read [x']) + 10*(read [y']) + (read [z']))
f (x':y':z':l) = let x = (read [x'])
                     y = (read [y'])
                     z = (read [z'])
                 in
                 if (abs $ 753 - (100*x + 10*y + z)) <= f (y':z':l)
                   then abs $ 753 - (100*x + 10*y + z)
                   else f (y':z':l)

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