main = do
  x <- getLine
  let xs = momo x
  print $ sisi (gosan xs)

momo :: String -> [Int]
momo (x:xs) = (read [x] :: Int) : momo xs
momo _      = []

gosan :: [Int] -> [Int]
gosan (x:y:z:ss) = 100*x + 10*y + z : gosan (y:z:ss)
gosan _          = []

sisi :: [Int] -> Int
sisi xs = minimum $ map (abs . (-) 753) xs