Problem:
 Score : 300 points    Problem Statement Takahashi participated in a contest on AtCoder.  The contest had N problems.  Takahashi made M submissions during the contest.  The i -th submission was made for the p_i -th problem and received the verdict S_i ( AC or WA ).  The number of Takahashi's correct answers is the number of problems on which he received an AC once or more.  The number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WA s received before receiving an AC for the first time on that problem.  Find the numbers of Takahashi's correct answers and penalties.      Constraints  N , M , and p_i are integers.  1 \leq N \leq 10^5  0 \leq M \leq 10^5  1 \leq p_i \leq N  S_i is AC or WA .         Input Input is given from Standard Input in the following format:  N  M  p_1  S_1  :  p_M  S_M       Output Print the number of Takahashi's correct answers and the number of Takahashi's penalties.        Sample Input 1 2 5
1 WA
1 AC
2 WA
2 AC
2 WA      Sample Output 1 2 2  In his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.  In his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.  Thus, he has two correct answers and two penalties.       Sample Input 2 100000 3
7777 AC
7777 AC
7777 AC      Sample Output 2 1 0  Note that it is pointless to get an AC more than once on the same problem.       Sample Input 3 6 0      Sample Output 3 0 0

Solution (Python):
n, m = input().split()
n = int(n)
m = int(m)
results = []
for i in range(m):
    results.append(list(input().split()))

wa = 0
ac = 0

dic = {}
for q, a in results:
    if q not in dic.keys():
        dic[q] = {"ac": False, "wa": 0}
    if dic[q]["ac"] is True:
        pass
    elif dic[q]["ac"] is False and a == "WA":
        dic[q]["wa"] += 1
    elif dic[q]["ac"] is False and a == "AC":
        ac += 1
        dic[q]["ac"] = True
for x in dic.keys():
    if dic[x]["ac"] is True:
        wa += dic[x]["wa"]

print(ac, wa)

Solution (Python):
n, m = map(int, input().split())
wa = [0] * n
ac = [0] * n
ps = []
score = 0
pena = 0
for _ in range(m):
    ps = input().split()
    if ps[1] == 'WA':
        wa[int(ps[0])-1] += 1
    else:
        if ac[int(ps[0])-1] == 0:
            score += 1
            pena += wa[int(ps[0])-1]
            ac[int(ps[0])-1] += 1
print(score, pena)

Solution (Python):
N,M=map(int,input().split())
A=[[0 for i in range(2)] for j in range(N+1)]
for i in range(M):
    p,s=input().split()
    p=int(p)
    if s=="AC": A[p][0]=1
    if s=="WA" and A[p][0]==0: A[p][1]+=1
AC=0
Pen=0
for row in A:
    AC+=row[0]
    Pen+=row[0]*row[1]
print(AC, Pen)

Solution (Python):
import sys
input = sys.stdin.readline

n,m = map(int,input().split())

ps = [ list(input().split()) for _ in range(m) ]

ac_count_list = [0]*n
wa_count_list = [0]*n
wa_count = 0

for i in range(m):
    q = int(ps[i][0])
    if ps[i][1] == "AC":
        if ac_count_list[q-1] == 0:
            ac_count_list[q-1] = 1
            wa_count += wa_count_list[q-1]
        else:
            pass
    else:
        if ac_count_list[q-1]==0:
            wa_count_list[q-1] += 1

print(sum(ac_count_list),wa_count)

Solution (Python):
n, m = map(int, input().split())
ans = []
ans_0 = []
for i in range(m):
    ans_0 = list(map(str, input().split()))
    ans.append(ans_0)
list0 = []
listpen = []
for j in range(n):
    list0.append(0)
for k in range(n):
    listpen.append(0)
sei = 0
pen = 0
for lis in ans:
    if list0[int(lis[0])-1] == 0:
        if lis[1] == "AC":
            sei += 1
            list0[int(lis[0])-1] = 1
        else:
            listpen[int(lis[0])-1] += 1
    else:
        pass
for l in range(n):
    if list0[l] == 1:
        pen += listpen[l]
print(str(sei)+" "+str(pen))

Solution (Python):
N,M = list(map(int,input().split()))
X = []
for i in range(M):
  tmp = [i for i in input().split()]
  X.append(tmp)

WAs = [0]*(N+1)
flags = [0]*(N+1)

AC = 0
WA = 0

for i in range(M):
  if X[i][1] == 'AC':
    if flags[int(X[i][0])] == 0:
      AC += 1
      WA += WAs[int(X[i][0])]
      flags[int(X[i][0])] = 1
  if X[i][1] == 'WA':
    if flags[int(X[i][0])] == 0:
      WAs[int(X[i][0])] += 1
      
print(AC,WA,sep=' ')

Solution (Python):
n, m = map(int, input().split())
ss = []

for i in range(m):
    t1, t2 = input().split()
    ss.append([t1, t2])

ss.sort(key=lambda x:x[0])

t = ''
ac = 0
wa = 0
awa = 0
cIsSolved = False
for s in ss:
    if s[0] != t:
        t = s[0]
        cIsSolved = False
        wa = 0
    if s[1] == 'AC' and not cIsSolved:
        cIsSolved = True
        ac += 1
        awa += wa
    if s[1] == 'WA' and not cIsSolved:
        wa += 1
print(ac, awa)

Solution (Python):
N,M = [int(i) for i in input().split()]
submissions = {str(i):[] for i in range(1,N+1)}
AC,WA = 0,0
for i in range(M):
    P,S = [j for j in input().split()]
    submissions[P].append(S)
for i in submissions:
    if 'AC' not in submissions[i]:
        continue
    for j in submissions[i]:
        if j == 'AC':
            AC+=1
            break
        WA +=1
print(AC,WA)

Solution (Python):
def main():
    N, M = map(int, input().split())
    a = [0] * N
    w = [0] * N

    for _ in range(M):
        p, s = map(str, input().split())
        if a[int(p) - 1] == 1:
            continue
        if s == "AC":
            a[int(p) - 1] = 1
        elif s == "WA":
            w[int(p) - 1] += 1

    wa = 0
    for i in range(N):
        if a[i] == 1:
            wa += w[i]

    print(sum(a), wa)


if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split())
cor = [[0] * 2 for i in range(N)]

for i in range(M):
    p, s = input().split()
    p = int(p)
    if(cor[p-1][1] != 1):
        if s == "AC":
            cor[p-1][1] = 1
        elif s == "WA":
            cor[p-1][0] += 1

AC = 0
WA = 0
for i in range(N):
    if cor[i][1] == 1:
        AC += 1
        WA += cor[i][0]
print(AC, WA)

Solution (Python):
N, M = map(int, input().split())
a = 0
b = 0
sp = dict()
for _ in range(M):
    s, p = input().split()
    if int(s) not in sp.keys():
        sp[int(s)] = [p]
    else:
        sp[int(s)].append(p)
        
a = 0
b = 0
for i, result in sp.items():
    if "AC" in result:
        a += 1
        b += result.index("AC")
    else:
        continue
print(a, b)

Solution (Python):
import sys


def main():
    tmp = str(input()).split(" ")
    n = int(tmp[0])
    m = int(tmp[1])
    p = []
    s = []
    for i in range(m):
        tmp = str(input()).split(" ")
        p.append(int(tmp[0]))
        s.append(str(tmp[1].replace("\n", "")))
    cnt = [[0, 0, False] for i in range(n)]
    for i, j in zip(p, s):
        if j == "WA" and not cnt[i-1][2]:
            cnt[i-1][1] += 1
        elif j == "AC" and not cnt[i-1][2]:
            cnt[i-1][0] = 1
            cnt[i-1][2] = True
    accnt = 0
    wacnt = 0
    for i in range(n):
        accnt += cnt[i][0]
        if cnt[i][2]:
            wacnt += cnt[i][1]
    print(str(accnt) + " " + str(wacnt))


if __name__ == '__main__':
    input = sys.stdin.readline
    main()

Solution (Python):
import numpy as np

N,M = map(int,input().split()) 

AC = np.array([0]*N)
WA = np.array([0]*N)

for i in range(M):
    p,S = input().split()
    if AC[int(p)-1] ==0 and S == "WA":
       WA[int(p)-1] += 1
    else:
        AC[int(p)-1] = 1


print(sum(AC),sum(AC*WA))

Solution (Python):
N,M = map(int, input().split())
P = []
S = []
result = {}
num_result = {}

for i in range(M):
    p,s = map(str, input().split())
    P.append(int(p))
    S.append(s)

ac = 0
wa = 0

for i in range(M):
    if S[i] == 'AC':
        if P[i] in result:
            if result[P[i]] == 'WA':
                ac += 1
                result[P[i]] = 'AC'
        else:
            result[P[i]] = 'AC'
            ac += 1
    elif S[i] == 'WA':
        if P[i] in result:
            if result[P[i]] == 'WA':
                num_result[P[i]] += 1
        else:
            result[P[i]] = 'WA'
            num_result[P[i]] = 1

for item in num_result:
    if result[item] != 'WA':
        wa += num_result[item]

print('{} {}'.format(ac,wa))

Solution (Python):
N,M = map(int,input().split())
p=[]
S=[]
d={"WA":-1,"AC":1}
for _ in range(M):
    i,j= input().split()
    p.append(int(i)-1)
    S.append(d[j])
    
status = [False for _ in range(N)]

wa = [0 for _ in range(N)]
ac = 0
for i in range(M):
    if not status[p[i]]:
        if S[i]==-1:
            wa[p[i]] += 1
        else:
            ac += 1
            status[p[i]] = True
    else:
        pass
wa2 = 0 
for i in range(N):
    if status[i]:
        wa2 += wa[i]
print(ac,wa2)

Solution (Python):
from collections import Counter
def counter(li, n):
    count = Counter()
    count.update(li)
    return count[n]
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
li_AC = [0]*N
count_WA = [0]*N
count_WA_total = 0
for i in range(M):
    p, S = input().split()
    p = int(p)
    if li_AC[p-1] == 0:
        if S == "AC":
            li_AC[p-1] = 1
            count_WA_total += count_WA[p-1]
        if S == "WA":
            count_WA[p-1] += 1
print(counter(li_AC, 1), count_WA_total)

Solution (Python):
R = lambda : input().split()

n, m = map(int, R())
a = [False] * n
b = [0] * n
for _ in range(m):
  p, s = R()
  p = int(p) - 1
  if s == 'AC':
    a[p] = True
  elif not a[p]:
    b[p] += 1
b =  [y for x, y in zip(a, b) if x]
print(len(b), sum(b))

Solution (Python):
n,m=map(int,input().split())
l=[input().split() for _ in range(m)]
arr=[]
ac,wa=0,0
acl=[False for _ in range(n)]
for r in l:
  p,s=int(r[0])-1,r[1]
  if s=='AC' and acl[p]==False:
    arr.append([p,s])
    acl[p]=True
  elif s=='WA' and acl[p]==False:
    arr.append([p,s])
    
for r in arr:
  p,s=r
  if s=='WA' and acl[p]:
    wa+=1
  elif s=='AC':
    ac+=1
    
print(ac,wa)

Solution (Python):
n, m = map(int, input().split())
wa = [0] * (n+1)
ac = [0] * (n+1)

for _ in range(m):
    p, s = input().split()
    if (not ac[int(p)]) and s == 'WA':
        wa[int(p)] += 1
    elif s == 'AC':
        ac[int(p)] = 1
sw = 0
for i in range(n+1):
    sw += ac[i] * wa[i]
print(sum(ac), sw)

Solution (Python):
n, m = [int(_) for _ in input().split()]
l = []
AC = 0
WA = 0
for i in range(m):
    l.append(input().split())
d = {}
for i in range(n):
    d[i + 1] = 0
for i in range(m):
    p, s = l[i]
    p = int(p)
    if s == 'WA':
        if d[p] != -1:
            d[p] += 1
    else:
        if d[p] != -1:
            AC += 1
            WA += d[p]
            d[p] = -1
    
    
print(AC, WA)

Solution (Python):
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

show_flg=False
show_flg=True


ans=0

n,m=LI()

a=[0]*n
w=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=='AC':
        a[p]=1
    elif s=='WA':
        if a[p]==0:
            w[p]+=1


for i in range(n):
    if a[i]==0:
        w[i]=0

print(sum(a),sum(w))

Solution (Python):
N,M = map(int,input().split())
PS = []

T = [0] * (N + 1)
A = 0
W = [0] * (N + 1)

ans = [0,0]

for i in range(M):
  p,s = input().split()
  p = int(p)
  PS.append([p,s])

for i in range(M):
  p = PS[i][0]
  s = PS[i][1]

  if T[p] == 0:
    if s == "AC":
      A += 1
      T[p] = "AC"
    elif s == "WA":
      W[p] += 1
      T[p] = "WA"
      
  elif T[p] == "AC":
    continue

  elif T[p] == "WA":
    if s == "AC":
      T[p] = "AC"
      A += 1
    elif s == "WA":
      W[p] += 1

w = 0

for i in range(1,N + 1):
  if T[i] == "AC":
    w += W[i]
      
print(A,w)

Solution (Python):
from itertools import compress

n, m = map(int, input().split())
ac = [0] * (n + 1)
wa = [0] * (n + 1)

for i in range(m):
    p, s = input().split()
    p = int(p)
    if ac[p]:
      continue
    if s == "AC":
        ac[p] = 1
    else:
        wa[p] += 1

print(sum(ac), sum(c for c in compress(wa, ac)))

Solution (Python):
N,M = list(map(int,input().split()))
colect_quest = [0]*N
WA_quest = [0]*N
for i in range(M):
    pi,si = list(map(str,input().split()))
    pi = int(pi)
    if si == "AC":
        colect_quest[pi-1] = 1
    if si == "WA" and colect_quest[pi-1] != 1:
        WA_quest[pi-1] += 1
WA_count = 0
for i in range(len(WA_quest)):
    if colect_quest[i] == 1 :
        WA_count += WA_quest[i] 
print(sum(colect_quest),WA_count)

Solution (Python):
hist = []
nm = list(map(int, input().split()))
for i in range(nm[1]):
    a,b=input().split()
    hist.append((int(a), b))

ac = [0] * nm[0]
wa = [0] * nm[0]

for i in range(nm[1]):
    if hist[i][1] == "AC":
        if ac[hist[i][0]-1] != 1:
            ac[hist[i][0]-1] = 1
    elif hist[i][1] == "WA":
        if ac[hist[i][0]-1] != 1:
            wa[hist[i][0]-1] = wa[hist[i][0]-1] + 1


for i in range(nm[0]):
    wa[i] = wa[i] * ac[i]

print(sum(ac), sum(wa))

Solution (Python):


N, M = map(int, input().split())
P = list()
S = list()
for i in range(M):
    p, s = map(str, input().split())
    P.append(int(p))
    S.append(s)

ac = 0
penalty = 0
if M == 0:
    print(ac, penalty)
    exit()

ac_list = [0] * N
wa_list = [0] * N
for i in range(M):
    if S[i] == 'AC' and ac_list[P[i] - 1] == 0:
        ac_list[P[i] - 1] = 1
        ac += 1
    elif S[i] == 'WA' and ac_list[P[i] - 1] == 0:
        wa_list[P[i] - 1] += 1

for i in range(N):
    if ac_list[i] == 1:
        penalty += wa_list[i]

print(ac, penalty)

Solution (Python):
N, M = [int(i) for i in input().split()]
ans_list = [list(input().split()) for i in range(M)]
ref_list = [0]*N
pena_list = [0]*N
for i, j in ans_list:
    if ref_list[int(i)-1]==0:
        if j == "AC":
            ref_list[int(i)-1]=1
        else:
            pena_list[int(i)-1] = pena_list[int(i)-1]+1
ok_count = 0
pena_num = 0
for i in ref_list:
    if int(i) == 1:
        ok_count += 1
for i, j in zip(ref_list, pena_list):
    if i==1:
        pena_num += j
print(ok_count, pena_num)

Solution (Python):
n,m = [int(i) for i in input().split()]
l = [[i for i in input().split()] for _ in range(m)]

ac = 0
wa = 0
problems = [[0,0] for _ in range(n)]
for i in l:
    if i[1] == 'WA' and problems[int(i[0])-1][0] == 0:
        problems[int(i[0])-1][1] += 1
    elif i[1] == 'AC' and problems[int(i[0])-1][0] == 0:
        problems[int(i[0])-1][0] = 1
    else:
        pass


for i in problems:
    ac += i[0]
    wa += i[1] if i[0] > 0 else 0
    
print(ac,wa)

Solution (Python):
i = list(map(int, input().split()))
accept = [0] * i[0]
miss = [0] * i[0]

for j in range(i[1]):
    s = input().split()
    if(accept[int(s[0]) - 1] == 1):
        
        print('',end='')
        pass
    elif(s[1] == 'AC'):
        accept[int(s[0]) - 1] = 1
    else:
        miss[int(s[0]) - 1] += 1

for j in range(i[0]):
    if(accept[j] == 0):
        miss[j] = 0
print(sum(accept), sum(miss))

Solution (Python):
N,M = map(int,input().split())
di = {}
pe = 0
ac = 0
for i in range(M):
    inp = input().split(" ")
    if inp[1] == "WA":
        if inp[0] in di:
            if di[inp[0]] >= 1:
                di[inp[0]] += 1
        else:
            di[inp[0]] = 1
            
            
    else:
        if inp[0] in di:
            pe += di[inp[0]]
            di[inp[0]] = 0
        di[inp[0]] = 0
        
for v in di.values():
    if v == 0:
        ac += 1
print(str(ac)+" "+str(pe))

Solution (Python):
n, m = map(int, input().split())

key = [0]*n
wa = [0]*n
for i in range(m):
    p, s = map(str, input().split())
    p = int(p)
    if s == "WA":
        if key[p-1]:
            continue
        else:
            wa[p-1] = wa[p-1]+1
    if s == "AC":
        if key[p-1]:
            continue
        else:
            key[p-1] = True
ac = sum(key)
wan = 0
for i in range(n):
    if key[i]:
        wan += wa[i]
print(ac, wan)

Solution (Python):
import sys

def resolve():
    input = sys.stdin.readline
    N,M=map(int,input().rstrip().split())
    Q=[list(input().rstrip().split()) for _ in range(M)]

    c=[0 for _ in range(N)]
    flag=[0 for _ in range(N)]

    for i in range(M):
        if Q[i][1]=="WA" and flag[int(Q[i][0])-1]==0:
            c[int(Q[i][0])-1]+=1
        if Q[i][1]=="AC":
            flag[int(Q[i][0])-1]=1
    
    
    
    
    ans=0
    ansAC=0
    for i in range(N):
        if flag[i]==1:
           ans+=c[i]
        ansAC+=flag[i]
    
    print('{:.15g}'.format(ansAC),'{:.15g}'.format(ans))


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 5
1 WA
1 AC
2 WA
2 AC
2 WA"""
        output = """2 2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """100000 3
7777 AC
7777 AC
7777 AC"""
        output = """1 0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """6 0"""
        output = """0 0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    
    resolve()

Solution (Python):

a,b = map(int,input().split())
dp = [0]*(100010)
qp = [0]*(100010)
for i in range(b):
    ta,tb = map(str,input().split())
    ta = int(ta)
    if qp[ta] == 0 :
        if tb == 'WA':
            dp[ta]+=1
        else :
            qp[ta]=1
ANS = 0
for i, j in zip(dp,qp):
    ANS += i*j
print(sum(qp),ANS)

Solution (Python):
N,M = map(int,input().split())
d = {}
P = {}
for i in range(1,N+1):
    d[i] = 0
    P[i] = 0
for i in range(M):
    p,s = map(str,input().split())
    q = int(p)
    if d[q] == 1:
        continue
    else:
        if s == 'AC':
            d[q] = 1
        else:
            P[q] += 1
ans1 = 0
ans2 = 0
for i in range(1,N+1):
    if d[i] == 1:
        ans1 += 1
        ans2 += P[i]
print(ans1,ans2)

Solution (Python):
n, m = (int(i) for i in input().split())
p = [None] * m
s = [None] * m
for i in range(m):
    p[i], s[i] = (j for j in input().split())
    p[i] = int(p[i])
    
pena = [0] * n
ac   = [0] * n

for i in range(m):
    q_index = p[i]-1
    if s[i] == 'AC': 
        ac[q_index] = 1
    if s[i] == 'WA':
        if ac[q_index] == 0: pena[q_index] += 1
        
ac_num = 0
pena_num = 0
for i in range(n):
    if ac[i] == 1:
        ac_num += 1
        pena_num += pena[i]

print(ac_num, pena_num)

Solution (Python):
N,M = list(map(int,input().split(" ")))
dic = {}
Acount = 0
Wcount = 0
tmp_w = {}
for i in range(M):
    x1,y1=[i for i in input().split(" ")]
    if x1 in dic:
        if dic[x1] == "WA" and y1 == "AC":
            Acount += 1
            Wcount = Wcount + tmp_w[x1]
            dic[x1] = y1
        elif dic[x1] == "WA" and y1 == "WA":
            tmp_w[x1] = tmp_w[x1] + 1
    else:
        if y1 == "AC":
            Acount += 1
            dic[x1] = y1
        else:
            tmp_w[x1] = 1
            dic[x1] = y1
print(Acount,Wcount)

Solution (Python):
N, M = map(int, input().split())
p = []
S = []
flag = [0 for i in range(N)]
wa_cnt_list = [0 for i in range(N)]
ac_cnt = 0
wa_cnt = 0


for i in range(M):
    pi, Si = input().split()
    p.append(int(pi))
    S.append(Si)
    




for i in range(M):
    
    if(flag[p[i]-1]==1):
        
        continue
    else:
        if(S[i]=='WA'):
            wa_cnt_list[p[i]-1] += 1
            
        else:
            flag[p[i]-1] = 1
            ac_cnt += 1
            wa_cnt += wa_cnt_list[p[i]-1]





print(ac_cnt, wa_cnt)

Solution (Python):
H = list(map(int, input().split()))
N = H[0]
M = H[1]
C = [0]*N
A = 0
W = [0]*N
w = 0
for i in range(M):
    X = input().split()
    if (C[int(X[0])-1]==0):
        if (X[1]=="AC"):
            C[int(X[0])-1]=1
            A += 1
        else:
            W[int(X[0])-1]+= 1

for i in range(N):
    if(C[i]==1):
        w+=W[i]
print(str(A)+" "+str(w))

Solution (Python):
N,M=map(int,input().split())
P=[]
S=[]
for i in range(M):
  p,s=map(str,input().split())
  P.append(int(p))
  S.append(s)
ac=0
wa=0
U=[0]*(N+1)
T=[0]*(N+1)



for i in range(M):
  if S[i]=="AC":
    U[P[i]]=1
  elif S[i]=="WA" and U[P[i]]!=1:
    T[P[i]] += 1
for i in range(N+1):
  if U[i]==0:
    T[i]=0
print(sum(U),sum(T))

Solution (Python):
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]


def sosu(x):
    for i in range(2, int(sqrt(x)+1)):
        if x % i == 0:
            return False
    return True


mod = 1000000007
inf = float('INF')


def A():
    A = 'abcdefghijklmnopqrstuvwxyz'
    C = input().rstrip()
    p = 0
    for i in A:
        if C == i:
            p = 1
            continue
        if p == 1:
            print(i)
            return

    return




def B():
    N,K,M = LI()
    A = LI()
    ans=M*N- sum(A)
    if ans>K:
        print(-1)
    elif ans<0:
        print(0)
    else:
        print(ans)


    return




def true():
    S = input()
    S = S[:-1]

    tmp = 0
    for x in range(1 << (len(S)-1)):
        func = S[-1]
        for i in range(len(S)-1):
            if(x & (1 << i)):
                tmp += int(func)
                func = S[-2-i]
            else:
                func = S[-2-i]+func
        tmp += int(func)
    print(tmp)

    return


def C():
    N, M = LI()
    P=[]
    S=[]
    count=set([])
    ans=[0]*1000000
    realans=0
    for i in range(M):

        p,s=input().split()
        p=int(p)
        if s=='AC':
            realans+=ans[p]
            count.add(p)
            ans[p]=0
        if s=='WA' and p not in count:
            
            ans[p]+=1
  


    
    print(len(count),realans)
    

        


        




def D():

    a, b, x = LI()
    BIG = a*a*b/2
    if x > BIG:
        y = 2*b-(2*x/a/a)
        print(math.degrees(math.atan(y/a)))
    else:
        y = 2*x/a/b
        print(math.degrees(math.atan(b/y)))
    return




def E():
    N, K = LI()
    A = LI()
    F = LI()
    A.sort(reverse=True)
    F.sort()
    cost = []
    for i in range(len(N)):
        cost.append(A[i]*F[i])

    a = F[cost.index(max(cost))]

    return




def F():
    N, M = LI()

    value = [0] * M
    power = [0] * M
    for i in range(M):
        a, b = LI()
        value[i] = a
        c = LI()
        L = ['0'] * N
        for k in c:
            L[k - 1] = '1'
        bint = ''.join(L)
        power[i] = int(bint, 2)
    bint = ''.join(list(['1'] * N))
    dp = [inf] * (int(bint, 2)+1)
    t = 0
    cost = 0

    dp[0] = 0
    for s in range(int(bint, 2) + 1):
        for i in range(M):
            t = s | power[i]
            cost = dp[s] + value[i]
            dp[t] = min(dp[t], cost)
    print(-1) if(dp[-1] == inf) else print(dp[-1])

    return

    



def solution(S):
    
    N = len(S)

    pass



if __name__ == '__main__':

    C()

Solution (Python):
n,m=map(int,input().split())
wa_check=[0 for _ in range(n+1)]
ac_check=[0 for _ in range(n+1)]
for i in range(m):
    p,s=input().split()
    p=int(p)
    if(ac_check[p]==0):
        if(s=='AC'):
            ac_check[p]=1
        else:
            wa_check[p]+=1
wa_ans=[wa_check[i] for i in range(n+1) if ac_check[i]!=0]
print(sum(ac_check),sum(wa_ans))

Solution (Python):
problem_num, sub_num = map(int, input().split())
ac = 0
wa = 0
rem_ac = {}
rem_wa = {}
for _ in range(sub_num):
    problem, result = input().split()
    
    if problem in rem_ac.keys():
        
        if rem_ac[problem] == 1:
            continue
        
        else:
            if result == 'WA':
                rem_wa[problem] += 1
                wa += 1
            else:
                ac += 1
                rem_ac[problem] = 1
    
    else:
        rem_ac[problem] = 0
        rem_wa[problem] = 0
        if result == 'WA':
            rem_wa[problem] += 1
            wa += 1
        else:
            ac += 1
            rem_ac[problem] = 1

for key, value in rem_ac.items():
    if value == 0:
        wa -= rem_wa[key]

print(ac, wa)

Solution (Python):
mon,sub=map(int,input().split())
sei,pen=0,0
f=0
l=[0 for i in range(mon)]
ll=[0 for i in range(mon)]
for i in range(sub):
  n,re=input().split()
  n=int(n)
  if l[n-1]==1:f%=2
  elif re=="WA":ll[n-1]+=1
  else:
    l[n-1]=1
    sei+=1
    pen+=ll[n-1]
print(sei,pen)

Solution (Python):
cin=input().split()
N=int(cin[0])
M=int(cin[1])


result={}
ac=0
was={}
for i in range(M):
    cin=input().split()
    p=int(cin[0])
    S=str(cin[1])

    log=result.get(p,None)
    if S == "AC" and log != "AC":
        ac+=1
        result[p]="AC"

    if S == "WA" and log != "AC":
        was[p]=was.get(p,0)+1

wa=0
for k,v in result.items():
    if v == "AC":
        wa+=was.get(k,0)
print(str(ac)+" "+str(wa))

Solution (Python):
n, m = [int(x) for x in input().split()]

answers = []
for x in range(m):
    answers.append(input().split())

correct_answers = set([answer[0] for answer in answers if answer[1] == "AC"])

temp = {k[0]: [] for k in answers}
for x in answers:
    temp[x[0]].append(x[1])

penalties = 0
for x in temp:
    if (temp[x].count("AC") > 0):
        G = temp[x][:temp[x].index("AC")]
        penalties += len(G)


print(len(correct_answers), penalties)

Solution (Python):


n, m = map(int, input().split(' '))
pro = [0 for _ in range(n + 1)]

ac_cnt = 0
wa_cnt = 0
for i in range(m):
    idx, res = input().split(' ')
    idx = int(idx)
    if pro[idx] == 'AC':
        continue
    if res == 'AC':
        wa_cnt += pro[idx]
        pro[idx] = 'AC'
        ac_cnt += 1
    else:
        pro[idx] += 1
print(ac_cnt, wa_cnt)

Solution (Python):
n, m = input().split()
a = [False] * int(n)
b = [0] * int(n)
AC = 0
WA = 0
for i in range(int(m)):
    p, s = input().split()
    if(s == "AC" and a[int(p) - 1] == False):
        a[int(p) - 1] = True
        AC += 1
        WA += b[int(p) - 1]

    if(s == "WA" and a[int(p) - 1] == False):
        b[int(p)-1] += 1

print(AC, WA)

Solution (Python):
n, m = map(int, input().split())
resultList = [[0 for i in range(2)] for j in range(n)]

for i in range(m) :
    result = input().split()
    prob = int(result[0]) - 1
    
    if result[1] == 'AC' and resultList[prob][0] == 0 :
        resultList[prob][0] = 1
    if result[1] == 'WA' and resultList[prob][0] == 0 :
        resultList[prob][1] += 1



ansAC = 0
ansWA = 0
for i in range(n) :
    ansAC += resultList[i][0]
    if resultList[i][0] == 1 :
        ansWA += resultList[i][1]

print(ansAC, ansWA)

Solution (Python):


N, M = map(int, input().split())

LIST = [[0, 0] for _ in range(N)]
WA = 0
AC = 0
for i in range(M):
    P, S = input().split()
    if LIST[int(P)-1][0] == 0:
        if S == "AC":
            LIST[int(P)-1][0] = 1
        else:
            LIST[int(P)-1][1] += 1
for i in range(N):
    if LIST[i][0] == 1:
        AC += 1
        WA += LIST[i][1]
print("{} {}".format(AC, WA))

Solution (Python):
A = list(map(int , input().split()))
x = []
for i in range(A[1]):
    X=list(input().split())
    x.append(X)
di = {}
for i in x:
    di[int(i[0])] = []
for i in x:
    di[int(i[0])].append(i[1])
sei = 0
go = 0
for k ,v in di.items():
    if 'AC' in v:
        sei += 1
    else:
        continue
    go += v.index('AC')
print('{} {}'.format(sei,go))

Solution (Python):
from bisect import bisect_right, bisect_left
from itertools import groupby, permutations, combinations
from fractions import gcd
import numpy as np
from sys import stdin, stderr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def main():
    N, M = [int(x) for x in input().split()]
    isAC = [False] * (N+1)
    cntWA = [0] * (N+1)
    cntAC = 0
    cntPN = 0
    for i in range(M):
        p, s = input().split()
        p = int(p)
        if not isAC[p]:
            if s == "AC":
                isAC[p] = True
                cntAC += 1
            else:
                cntWA[p] += 1
    for i in range(1, N+1):
        if isAC[i]:
            cntPN += cntWA[i]

    return " ".join([str(cntAC), str(cntPN)])


if __name__ == "__main__":
    print(main())