n,q=map(int,input().split())
s=input()
masu=[['-',0]]
for si in s:
    masu.append([si,1])
masu.append(['-',0])
length=len(masu)-1
for _ in range(q):
    t,d=input().split()
    if d == 'R':
        d = 1
    else:
        d = -1
    for i in range(1,length):
        if masu[i][0] == t:
            masu[i+d][1] += masu[i][1]
            masu[i][1] = 0

ans=0
for i in range(1,length):
    ans+=masu[i][1]
print(ans)