program answer
  implicit none

  integer :: N, M, i, ans
  integer, allocatable :: p(:), T(:), un(:)
  character, allocatable :: S(:)
  read(*,*) N, M
  allocate(p(M))
  allocate(S(M))
  allocate(T(N))
  allocate(un(N))
  do i = 1, M
     read(*,*) p(i), S(i)
  end do

  T=0
  un=0
  ans=0
  un=0
  do i = 1, M
     if(T(p(i))==0) then
        if(S(i)=='A') then
           ans=ans+1
           T(p(i))=1
        else
           un(p(i))=un(p(i))+1
        end if
     end if
  end do

  write(*,*) ans, sum(un)

  deallocate(p)
  deallocate(T)
  deallocate(un)
  
  stop
 end program answe