n,q=map(int,input().split())
s=input()
masu=[['-',0]]
for si in s:
    masu.append([si,1])
masu.append(['-',0])

for _ in range(q):
    t,d=input().split()
    for i in range(1,len(masu)-1):
        if masu[i][0] == t and masu[i][1] >= 1:
            if d == 'R':
                masu[i+1][1] += masu[i][1]
            else:
                masu[i-1][1] += masu[i][1] 
            masu[i][1] = 0

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