N,Q = map(int,input("N,Q").split(" "))
s = str(input("s"))
L = [1 for i in range(N)]
L_next = [1 for i in range(N)]

S_dict = {}
for i in range(1,N-1):
    if s[i] in S_dict:
        S_dict[s[i]].append(i)
    else:
        S_dict[s[i]] = [i]

for i in range(Q):
    ti,di = map(str,input("t,d").split(" "))

    if di == 'L':
        if ti == s[0]:
            L_next[0] =0
        
        if ti == s[N-1]:
            L_next[N-2] +=L[N-1]
            L_next[N-1] -=L[N-1]
        
        if ti in S_dict:
            for j in S_dict[ti]:
                L_next[j-1] += L[j]
                L_next[j] -= L[j]

    if di =='R':
        if ti == s[0] :
            L_next[1] +=L[0]
            L_next[0] -=L[0]   
        
        if ti == s[N-1]:
            L_next[N-1] = 0
        
        if ti in S_dict:
    
            for j in S_dict[ti]:
                L_next[j+1] += L[j]
                L_next[j] -= L[j]
    L = L_next.copy()

ans = sum(L)
print(ans)
