import Data.Char

main = do
  ss <- getLine
  let x = func ss
  print (minimum x)

func :: String -> [Int]
func [a, b, c] = [abs (753 - ((digitToInt a * 100) + (digitToInt b * 10) + digitToInt c))]
func (a:b:c:xs) = abs (753 -  ((digitToInt a * 100) + (digitToInt b * 10) + digitToInt c)) : func (b:c:xs)
