# coding: utf-8
N, Q = map(int, input().split())
s = list(input())
gorem = [1]*N
#print(gorem)
i = 0
while i < Q:
    t, d = map(str, input().split())
    for j in range(N):
        if t == s[j] and d == 'R' and j == N-1 and gorem[N-1] > 0:
            gorem[N-1] = 0
        elif t == s[j] and d == 'R':
                gorem[j+1] += gorem[j]
                gorem[j] = 0

        elif t == s[j] and d == 'L' and j == 0 and gorem[0] > 0:
            gorem[0] = 0
        elif t == s[j] and d == 'L':
            gorem[j-1] += gorem[j]
            gorem[j] = 0
    i += 1
    #print(gorem)
    #print(gorem[0])
    #print(gorem[N-1])

print(sum(gorem))
