program prob3
    implicit none
    integer :: n, m
    integer, allocatable :: a(:)
    integer :: pena
    integer :: ac
    integer :: i, p
    character(1) :: s
    character(25) :: x, y

    read(*,*) n, m
    allocate(a(n))

    a = 0

    pena = 0
    ac = 0
    do i = 1, m
        read(*,*) p, s
        if(s == 'A') then
            if(a(p) /= -1)then
                pena = pena + a(p)
                ac = ac + 1
                a(p) = -1
            end if
        else
            if(a(p) /= -1)then
                a(p) = a(p) + 1
            end if
        end if
    end do
    write(x,*) ac
    write(y,*) pena
    write(*,'(a,1X,a)') trim(adjustl(x)), trim(adjustl(y)) 
    deallocate(a)

    stop
contains
end program prob3