N,Q = map(int,input().split())
s = input()
t,d = [],[]
for i in range(Q):
    t_next,d_next = input().split()
    t.append(t_next),d.append(d_next)
def golem_out(index):
    golem = [i for i in range(N)]
    for i in range(Q):
        if(s[golem[index]]==t[i]):
            if(d[i]=='R'):
                golem[index] += 1
                if(golem[index]==N):
                    return 'R'
            elif(d[i]=='L'):
                golem[index] -= 1
                if(golem[index]==-1):
                    return 'L'
    return False
#左にそれるゴーレムの数
def count_left():
    left,right = 0,N-1
    if(golem_out(0)!='L'):
        return 0
    if(golem_out(N-1)=='L'):
        return N-1
    while(right-left>1):
        if(golem_out(int((left+right)/2)) == 'L'):
            left = int((left+right)/2)
        else:
            right = int((left+right)/2)
    return right
def count_right():
    left,right=0,N-1
    if(golem_out(N-1)!='R'):
        return 0
    if(golem_out(0)=='R'):
        return N-1
    while(right-left>1):
        if(golem_out(int((left+right)/2)) == 'R'):
            right = int((left+right)/2)
        else:
            left = int((left+right)/2)
    return N-1-left
print(N - count_left()-count_right())