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