import re
N, Q = map(int, input().split())
s = input()
td =[]
goremu = [1] * N

for i in range(Q): 
    t, d = input().split()
 
    #文字列tの添字をすべて求めてt_listに格納
    t_list = []
    t_start = 0
    K = s.find(t, t_start)
    while K != -1:
        t_list.append(K)
        t_start = K + 1
        K = s.find(t, t_start)
 
    for i in t_list:
        if d == 'L':
            if i == 0:
                goremu[i] = 0
            else:
                goremu[i-1] += goremu[i]
                goremu[i] = 0
        if d == 'R':
            if i == N - 1:
                goremu[i] = 0
            else:
                goremu[i+1] += goremu[i]
                goremu[i] = 0
    if sum(goremu) == 0:
     break
print(sum(goremu))