main = do
    [s,t] <- lines <$> getContents
    let acc = 0
    print $ tenki s t acc
    
tenki _ _ 3 = 0
tenki s t acc = if (s!!acc)==(t!!acc)
   then 1 + tenki s t (acc+1)
   else 0 + tenki s t (acc+1)