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

ss = list(s)
nn = []

m = {}
i = 0
for c in ss:
    if c in m:
        m[c].append(i)
    else:
        m[c] = []
        m[c].append(i)
    i += 1
    nn.append(1)

LAST_N = N - 1

for i in range(Q):
    t, d = map(str, input().split())
    if not t in m:
        continue
    if d == 'L':
        for mi in m[t]:
            if 0 < mi:
                nn[mi - 1] += nn[mi]
            nn[mi] = 0
    else:
        for mi in m[t]:
            if mi < LAST_N:
                nn[mi + 1] += nn[mi]
            nn[mi] = 0

print(sum(nn))
