import Data.List

main = do
  s <- getLine
  t <- getLine
  print $ compute s t

compute :: String -> String -> Int
compute s t = minimum $ map (dist t) $ tails s

dist (t:ts) (s:ss) = dist ts ss + if t == s then 0 else 1
dist _ [] = 9999
dist [] _ = 0
