N, Q = map(int, input().split())

s = list(input())

t = [0] * Q
d = [0] * Q

for i in range(Q):
    t[i], d[i] = input().split()

# 各マスに存在するGolemの数を表す
Golem = [1] * N

for j in range(Q):
    for i, string in enumerate(s):
        if t[j] == string:

            if d[j] == "L":

                if i == 0:
                    Golem[i] = 0

                else:
                    if Golem[i - 1] != 0:
                        Golem[i - 1] += 1
                    if Golem[i] != 0:
                        Golem[i] -= 1

            else:

                if i == N - 1:
                    Golem[i] = 0

                else:
                    if Golem[i + 1] != 0:
                        Golem[i + 1] += 1
                    if Golem[i] != 0:
                        Golem[i] -= 1

ans = sum(Golem)
print(ans)