#TLE
N,Q=map(int,input().split())
s=input()
z=[1]*N#one
l=[]
two=[]
#for i in range(Q):
#    l.append(list(map(str,input().split())))
#print(l)
#print(z)
for i in range(Q):
    one=[]
    mid=[]
    l=list(map(str,input().split()))
    alpha=l[0]
    lr=l[1]
    for j in range(N):
        if s[j]==alpha:#A nara 0
            one.append(0)
            mid.append(z[j])
        else:
            one.append(z[j])
            mid.append(0)
    #print(one)
    #print(mid)
    #mid change to two
    if lr=='R':
        mid.insert(0,0)#mid[0] ni 0
        mid.pop(-1)
    #    for j in range(N):
    #        if =
    else:
        mid.pop(0)
        mid.append(0)
        #for j in range(N)
    #print("mid",mid)
    for j in range(N):
        z[j]=one[j]+mid[j]
    #print(z)
print(sum(z))
