N, Q = map(int, input().split())
s = input()
List = [list(map(str, input().split())) for i in range(Q)]

G = []
for i in range(N):
    G.append(1)

for i in range(Q):
    for j in range(N):
        if List[i][0] == s[j]:
            if List[i][1] == "L":
                if j - 1 >= 0:
                    G[j-1] += G[j]
            if List[i][1] == "R":
                if j + 1 < N:
                    G[j+1] += G[j]
            G[j] = 0

nokori = 0
for i in range(N):
    nokori += G[i]
print(nokori)
