import Data.List
import Data.Char
import Control.Monad
import Data.Ord

main = do
  s <- getLine
  let d = map digitToInt s
  let d' = [a*100+b*10+c|i<-[0..(length d)-3],let a=d!!i,let b=d!!(i+1),let c=d!!(i+2)]
  let d'' = map (\x -> (x,abs (753-x))) d'
  let d0 = head $ sortBy (comparing snd) d''
  putStrLn $ show $ snd d0
