N, Q = map(int, input().split())
s = input()
X = []
for _ in range(Q):
    t, d = input().split()
    X.append([t, 1 if d == "R" else -1])

def chk(k):
    i = k
    for x in X:
        if s[i] == x[0]:
            i += x[1]
            if i < 0:
                return -1
            if i >= N:
                return 1
    return 0

L, R = -1, N
while R-L>1:
    M = (L+R)//2
    if chk(M) < 0:
        L = M
    else:
        R = M

A = L

L, R = -1, N
while R-L>1:
    M = (L+R)//2
    if chk(M) > 0:
        R = M
    else:
        L = M

B = R
print(B-A-1)
