N, Q = map(int, input().split())
s = input()
go = {'L':-1, 'R':1}
position = [1 for i in range(N+2)]
col_dict = {}
for i in range(N):
    if s[i] in col_dict:
        col_dict[s[i]].append(i+1)
    else :
        col_dict[s[i]] = [i+1]
for _ in range(Q): 
    t, d = input().split()
    if t not in col_dict:
        continue
    for i in col_dict[t]:
      position[i + go[d]] += position[i]
      position[i] = 0
print(sum(position[1:N+1]))
