program main
  implicit none
  integer :: cnt, i
  character(3) :: s, t
  read *, s
  read *, t
  cnt = 0
  do i = 1, 3
    if (s(i:i) == t(i:i)) cnt = cnt + 1
  end do
  print "(i0)", cnt
end program main
