N, Q = map(int, input().split())
s = list(input())
g = [1]*N
t = ""
d = ""
sum = 0
for i in range(Q):
    t, d = map(str, input().split())
    for j in range(N):
        if s[j] == t:
            if d == "L" and j != 0:
                g[j-1] += g[j]
                g[j] = 0
            elif d == "L" and j ==0:
                g[j] = 0
            elif d == "R" and j != len(s)-1:
                g[j+1] += g[j]
                g[j] = 0
            elif d == "R" and j == len(s)-1:
                g[j] = 0
for i in range(N):
    sum += g[i]
print(sum)
