import numpy as np

N,Q = map(int,input().split(" "))
S = input()
st = set(S)
dic = { ch : [] for ch in S }
for idx,ch in enumerate(S):
    dic[ch].append(idx+1)

dic2 = { }
for key,value in dic.items():
    dic2[key] = (list(map(lambda x: x-1,value)) , value , list(map(lambda x: x+1,value)))
arr = np.ones(N+2)
arr[0],arr[N+1] = 0,0
f = np.vectorize(lambda x: max(x - 1,0))

for q in range(Q):
    t,d = map(str,input().split(" "))
    if not t in st:
        continue
    tp = dic2[t]
    if d == 'L':
        arr[tp[0]] += arr[tp[1]]
    else:
        arr[tp[2]] += arr[tp[1]]
    arr[tp[1]] = f(arr[tp[1]])

print(int(N - arr[0] - arr[-1]))
