n,q = map(int,input().split())
s=list(input())
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(input().split()))

    except:
        break;
        
a=[1]*(n+2)
#print(listA)
for j in range(q):
  for k in range(n):
    if s[k]==listA[j][0]:
      if listA[j][1]=="R":
        a[k+2]=a[k+1]+a[k+2]
        a[k+1]=0
        a[0]=0
        a[n+1]=0
      else:
        a[k]=a[k+1]+a[k]
        a[k+1]=0
        a[0]=0
        a[n+1]=0
      #print(a)
#print(a)
print(sum(a))