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

main :: IO ()
main = do
    s <- getLine
    print $ minimum $ map (abs.(753-).read) (f s)

f xs
    | length xs < 4 = [xs]
    | otherwise = take 3 xs : (f $ tail xs)