program main
  implicit none
  integer i,ans
  character(3) S,T
  read(*, *)S
  read(*, *)T
  !read(*, *) (L(i), i = 1,N)
  ans = 0
  do i = 1,3
    if (S(i:i) == T(i:i)) then
      ans = ans + 1
    endif
  enddo

  write(*, *) ans
end program main
