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

lt = []
ld = []

for q in range(Q):
    t, d = input().split()
    lt.append(t)
    ld.append(d)

pl = -1
pr = N

for q in range(Q-1, -1, -1):
    if ld[q] == 'L':
        if s[pl + 1] == lt[q]:
            pl += 1
    else:
        if s[pr - 1] == lt[q]:
            pr -= 1

print(max(pr - pl -1, 0))
