import re
n, q =map(int,input().split())
s = input()
k = [1 for _ in range(n)]

def gm(n,d,arr1):
    g =arr1[n]
    arr1[n] = 0
    if d =='L':
        if n != 0:
            arr1[n - 1] += g
    else:
        if n !=len(arr1) - 1:
            arr1[n + 1] += g
    return arr1

for _ in range(q):
    t,d =input().split()
    for m in re.finditer(t,s):
        gm(m.start(), d, k)
print(sum(k))
