# -*- coding: utf-8 -*-
N, Q = map(int, input().split())
S = input()
no = [1 for i in range(N)]
st = [[i for i, x in enumerate(S) if x == s] for s in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
for i in range(Q):
    t, d = input().split()
    if d == "L":
        for j in st[ord(t)-65]:
            if j > 0:
                no[j-1] += no[j]
            no[j] = 0
    else:
        for j in reversed(st[ord(t)-65]):
            if j < N-1:
                no[j+1] += no[j]
            no[j] = 0
print(sum(no))
