n,q = map(int,input().split())
s = input()
l = []
r = []
for i in range(q):
    t,d = input().split()
    if d == 'L':
        l.append(t)
    else:
        r.append(t)
l = l[::-1]
r = r[::-1]
res = 0
piv = 0
for c in l:
    if c == s[piv]:
        piv += 1
res += piv
s = s[::-1]
piv = 0
for c in r:
    if c == s[piv]:
        piv += 1
res += piv
print(n - res)
