n,q = map(int,input().split())
s = input()
t = [0]+[1]*(n)+[0]
d={}
ju=[]
for i in range(q):
    a,b = map(str,input().split())
    ju.append([a,b])
x0 = 1
x1 = n
p = 1
for i in range(q):
    if ju[i][0]==s[p-1] and ju[i][1]=="R":
        p+=1
    elif ju[i][0]==s[p-1] and ju[i][1]=="L":
        p-=1
    if p<1:
        break
if p<1:
    while(1):
        x2=0
        x = int((x0+x1)/2)+1
        for i in range(q):
            if ju[i][0]==s[x-1] and ju[i][1]=="R":
                x+=1
            elif ju[i][0]==s[x-1] and ju[i][1]=="L":
                x-=1
            if x<1:
                x0=int((x0+x1)/2)+1
                x2=1
                break
        if x2==0:
            x1=int((x0+x1)/2)
        if x0==x1:
            break
else:
    x1=0

p=n
y0=1
y1=n
for i in range(q):
    if ju[i][0]==s[p-1] and ju[i][1]=="R":
        p+=1
    elif ju[i][0]==s[p-1] and ju[i][1]=="L":
        p-=1
    if p>n:
        break
if p>n:
    while(1):
        y2=0
        y = int((y0+y1)/2)
        for i in range(q):
            if ju[i][0]==s[y-1] and ju[i][1]=="R":
                y+=1
            elif ju[i][0]==s[y-1] and ju[i][1]=="L":
                y-=1
            if y>n:
                y1=int((y0+y1)/2)
                y2=1
                break
        if y2==0:
            y0=int((y0+y1)/2)+1
        if y0==y1:
            break
else:
    y1=n+1
print(y1-x1-1)