import Control.Monad.State
main = do
  s <- getLine 
  print $ solve s

solve :: String -> Int
solve s@(fs:ss) = 
  if length s < 3
    then 753
    else
      min diff (solve ss)
      where val =read $ take 3 s
            diff = abs (753-val)