N, Q = [int(x) for x in input().split()]
G = [1] * N

index={}
for i,s in enumerate(input().strip()):
    index.setdefault(s, []).append(i)
import sys
input = sys.stdin.readline

for _ in range(Q):
    t, _, d = input()[:3]
    if t not in index:
        continue

    if d == 'L':
        for i in index[t]:
            if i > 0:
                G[i-1]+= G[i]
            G[i] = 0

    else:
        for i in index[t]:
            if i < N - 1:
                G[i+1] += G[i]
            G[i] = 0
print(sum(G)) 
