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 = [0]*N
for n in range(N):
    mas[n] = S[n]
cnt = [1]*N

for q in range(Q):
    if d[q] == 'L':
        for n in range(N):
            if mas[n] == t[q]:
                if n == 0:
                    cnt[n] = 0
                else:
                    cnt[n-1] += cnt[n]
                    cnt[n] = 0 
    else:
        for n in reversed(range(N)):
            if mas[n] == t[q]:
                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)