N,Q = map(int, input().split())
S = input()

t = [0]*Q
d = [0]*Q
for q in range(Q):
    t[q],d[q] = map(str, input().split())

mas = [[-1] for i in range(26)]
for n in range(N):
    mas[ord(S[n])-65].append(n)

cnt = [1]*N

for q in range(Q):
    if d[q] == 'L':
        for n in mas[ord(t[q])-65]:
            if n == -1:
                continue
            if n == 0:
                cnt[n] = 0
            else:
                cnt[n-1] += cnt[n]
                cnt[n] = 0 
    else:
        for n in reversed(mas[ord(t[q])-65]):
            if n == -1:
                continue
            if n == N-1:
                cnt[n] = 0
            else:
                cnt[n+1] += cnt[n]
                cnt[n] = 0

ans = 0
for n in range(N):
    ans += cnt[n]
print(ans)