program tenki
    implicit none
    integer :: i, cnt = 0
    character(3) s, t
    read *, s(1:3)
    read *, t(1:3)
    do i = 1, 3
        if(s(i:i) .eq. t(i:i))then
            cnt = cnt + 1
        end if
    end do
    print *, cnt
end program