N, Q = map(int, input().split())
S = input()
tds = [input().split() for _ in range(Q)]

cells = [1] * N

tmap = {}
for i, s in enumerate(S):
    if not s in tmap:
        tmap[s] = [i]
    else:
        tmap[s].append(i)

for t, d in tds:
    targets = tmap.get(t)
    if targets is None:
        continue
    if d == 'L':
        for i in targets:
            tmp = cells[i]
            cells[i] = 0
            if i > 0:
                cells[i-1] += tmp
    else:
        for i in reversed(targets):
            tmp = cells[i]
            cells[i] = 0
            if i < N-1:
                cells[i+1] += tmp

print(sum(cells))
