import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  arr <- map digitToInt <$> getLine
  print $ minimum $ map (\i -> abs $ (arr !! i * 100 + arr !! (i + 1) * 10 + arr !! (i + 2)) - 753 ) [0..((length arr) - 3)]