N,Q=input().split()
N=int(N)
Q=int(Q)
s=input()
t=['']*Q
d=['']*Q
for i in range(Q):
    t[i],d[i]=input().split()


s=s[0]+s+s[-1]
    
t.reverse()
d.reverse()

count={}
flagL=0
flagR=N+2-1


for i in range(Q):
    if d[i]=='R':
        if s[flagR-1]==t[i]:
            flagR-=1
            print(t[i]+':'+d[i])
    else:
        if s[flagL+1]==t[i]:
            flagL+=1
            print(t[i]+':'+d[i])
   
print(flagR-flagL-1)
     
