program kadai
    implicit none
character(len=3)  ::  S,T
integer  ::  a,i


read(*,*) S
read(*,*) T
a=0
do i=1,3
if (S(i:i)==T(i:i)) then
    a=a+1
end if
end do

write(*,*) a


stop
contains



end program kadai
