import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
S = input().rstrip()
Query = []
for _ in range(Q):
    Alp, LR = map(str, input().rstrip().split())
    Query.append((Alp, LR))

left = 0
for Alp, LR in reversed(Query):
    if S[left] == Alp and LR == "L":
        left += 1
right = 0
for Alp, LR in reversed(Query):
    if S[N-1-right] == Alp and LR == "R":
        right += 1
print(max(0, N-left-right))