main ::IO()
main = do
    line <- getLine
    print $ minimum(func line)

func :: String -> [Int]
func [a, b, c] = [abs (753 - (read [a, b, c]))]
func (a:b:c:xs) = (head $ func [a, b, c]) : func (b:c:xs)
func [] = func (replicate 3 '0')
func [a] = func ((replicate 2 '0') ++ [a])
func [a, b] = func (['0', a, b])
