import math
import copy
from collections import Counter
from _ast import Or
 
 
 
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:
 
            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l
 

a=nCast(input().split())
b=input()
c=list()
d=0
for idx in range(0,a[1]):
    c.append(input().split(" "))

def move(ss,k):
    beg=k
    chr=ss[k]
  
        
    for step in c:
        
        if(step[0]!=chr):
            continue

        if(beg==0 and step[1]=="L"):
            return "L"
        if(beg==len(ss)-1 and step[1]=="R"):
            return "R"
        if(step[1]=="L"):
            chr=ss[beg-1]
            beg=beg-1
        if(step[1]=="R"):
            chr=ss[beg+1]
            beg=beg+1
            
def solve(b,beg,end):
    global d
    if beg>end:
        return 
    pos=(beg+end)/2
    pos=int(pos)
    res=move(b,pos)

    if res=="L":
        solve(b,pos+1,end)
    elif res=="R":
        solve(b,beg,pos-1)
        end=pos-1
    else:
        d=d+1 
        solve(b,pos+1,end)
        solve(b,beg,pos-1)
                   
   

def func():
    solve(b,0,len(b)-1)
    return d
print(func())
