# -*- coding: utf-8 -*-
N, Q = map(int, input().split())
s = input()
t = [''] * Q
d = [''] * Q
for i in range(Q):
    t[i], d[i] = input().split()
G = [1] * N

for i in range(Q):
    for j in range(N):
        if t[i] == s[j]:
            if d[i] == 'R':
                if j != N - 1:
                    G[j + 1] += G[j]
                G[j] = 0
            elif d[i] == 'L':
                if j != 0:
                    G[j - 1] += G[j]
                G[j] = 0
print(sum(G))