n,q=map(int,input().split())
s=input()
t=[]
d=[]
robot=[1]*n
ans=0
for i in range(q):
    a,b=map(str,input().split())
    t.append(a)
    d.append(b)

for i in range(q):
    if d[i]=='L':
        for j in range(n):
            if t[i]==s[j]:
                if j!=0:
                    robot[j-1]=robot[j-1]+robot[j]
                robot[j]=0
    if d[i]=='R':
        for j in range(n):
            if t[i]==s[n-1-j]:
                if j!=0:
                    robot[n-j]=robot[n-j]+robot[n-j-1]
                robot[n-j-1]=0

for i in robot:
    ans=ans+i

print(ans)
