let tenki s t =
  if s.[0] = t.[0] then if s.[1] = t.[1] then if s.[2] = t.[2] then 3
                                                               else 2
                                         else if s.[2] = t.[2] then 2
                                                               else 1
                   else if s.[1] = t.[1] then if s.[2] = t.[2] then 2
                                                               else 1
                                         else if s.[2] = t.[2] then 1
                                                               else 0
let s = read_line ()
let t = read_line ()
let () = Printf.printf "%d\n" (tenki s t)