from collections import*
from copy import deepcopy
from bisect import*
n,q=map(int,input().split())
ans=0
 
d=defaultdict(list)
d2=defaultdict(int)
mad=defaultdict(int)
mid=defaultdict(int)
for k,v in enumerate(input()):
    d[v].append(k)
for i in range(q):
    s,t=input().split()
    if t=="L":
        d2[s]-=1
    else:
        d2[s]+=1
    if d2[s]<mid[s]:
        mid[s]=d2[s]
    elif d2[s]>mad[s]:
        mad[s]=d2[s]
 
for k,v in d.items():
    x=abs(mid[k])
    y=mad[k]
    #print(v,x,y)
    ans+=(bisect_left(v,n-y-1)-bisect_left(v,x))
print(n-ans)