import numpy as np

nq=input().split()
N=int(nq[0])
Q=int(nq[1])
lst=[1]*(N+2)
lr_dic={}
s=input()
lr={'L':-1,'R':1}
for i in range(N):
    if not(s[i] in lr_dic):
        lr_dic[s[i]]=[0]*N
    lr_dic[s[i]][i]=1

for i in range(Q):
    line = input().split()
    if not line[0] in lr_dic:
        continue
    masked = list(np.array(lst[1:N+1])*np.array(lr_dic[line[0]]))
    #print(masked)
    minus=[0]+masked+[0]
    if line[1]=='L':
        plus = masked + [0,0]
    else:
        plus = [0,0] + masked
    lst = np.array(lst) + np.array(plus) - np.array(minus)
    lst = lst.tolist()
    #print(lst)


print(sum(lst[1:N+1]))