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)
for i in range(Q):
    p = (s==t[i][0]).astype("int32")
    if t[i][1]=="R":
        trans = p*counts
        counts -= p*counts
        counts[1:] += trans[:-1]
    else:
        trans = p*counts
        counts -= p*counts
        counts[:-1] += trans[1:]
print(int(counts.sum()))