There are N squares numbered 1 to N from left to right. Each square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square.  Snuke cast Q spells to move the golems.  The i-th spell consisted of two characters t_i and d_i, where d_i is `L` or `R`. When Snuke cast this spell, for each square with the character t_i, all golems on that square moved to the square adjacent to the left if d_i is `L`, and moved to the square adjacent to the right if d_i is `R`.  However, when a golem tried to move left from Square 1 or move right from Square N, it disappeared.  Find the number of golems remaining after Snuke cast the Q spells.
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
    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
    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
N - count_left()-count_right()
N,Q = map(int,input().split())
S = '_'+input()+'_'
td = [input().split() for _ in range(Q)]
R = N+1
L = 0
for i in range(Q-1,-1,-1):
    t,d = td[i]
    if t == S[R-1] and d == 'R':
        R -= 1
    elif t == S[R] and d == 'L':
        R += 1
    if t == S[L+1] and d == 'L':
        L += 1
    elif t == S[L] and d == 'R':
        L -= 1
print(max(0,R-L-1))