N, Q = list(map(int, input().split()))
s = input()


pos = {}
for i, c in enumerate(s):
    if c in pos:
        pos[c].append(i)
    else:
        pos[c] = [i]


n = [1 for _ in range(N)]

for i in range(Q):
    t,d = input().split()

    if t not in pos:
        continue
    
    for p in pos[t]:
        if d=='L':
            if p > 0:
                n[p-1] = n[p-1]+n[p]
            n[p] = 0
        else:
            if p < N-1:
                n[p+1] = n[p+1]+n[p]
            n[p] = 0


print(sum(n))
