import numpy as np
N, Q = map(int,input().split())
s = np.array(list(input()))
t = []
for _ in range(Q):
    t.append(list(input().split()))
counts = np.ones(N)
alpha = "ABCDEFGHIJKLMNOPZQRSTUWXYZ"
transfer = {}
for st in alpha:
    transfer[st] = (s==st).astype("int32")
for i in range(Q):
    trans = transfer[t[i][0]]*counts
    counts -= trans
    if t[i][1]=="R":
        counts[1:] += trans[:-1]
    else:
        counts[:-1] += trans[1:]
print(int(counts.sum()))