program main
    implicit none
    character(3):: S, T
    integer:: i, day

    read*, S, T
    day = 0

    do i = 1, 3
        if(S(i:i) == T(i:i)) then
            day = day + 1
        endif
    enddo

    print*, day
end program