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