program sample
    implicit none
    character(2)::s
    integer(8) :: i,j,m,n,w,p
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n,m
    allocate(x(n))
    x(:)=0
    w=0
    do i=1,m
        read(*,*)p,s
        if(s .eq. 'AC')then
            x(p)=1
        else if(x(p)==0)then
            w=w+1
        end if
    end do


    write(*,*) sum(x),w
  
    stop
end program sample
  

