n,q=(int(i) for i in input().split())
s=list(input())
l=[1]*n
l.insert(0,0);l.append(0)
lst=[]
sets=list(set(s))
num=[[] for i in range(len(sets))]
for c,d in enumerate(s):
    num[ord(d)-65].append(c)
for i in [0]*q:
    lst.append(tuple(input().split()))
for i in lst:
    a,b=i
    for j in num[ord(a)-65]:
        if b=='R':
            l[j+2]+=l[j+1]
        else:
            l[j]+=l[j+1]
        l[j+1]=0
print(n-(l[0]+l[-1]))