import Data.List                                                                                                                                      
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  a <- minimum . map (abs . (753-) . read . take 3) . filter ((>=3) . length) . tails  <$> getLine                                                    
  print a