n,q=map(int,input().split())
s=input()
x=[1]*n
for _ in range(q):
    c,d=input().split()
    for i,char in enumerate(s):
        if char == c:
            if d=="L":
                if i==0:
                    x[i]=0
                else:
                    x[i-1]+=x[i]
                    x[i]=0
            else:
                if i==n-1:
                    x[n-1]=0
                else:
                    x[i+1]+=x[i]
                    x[i]=0
print(sum(x))
