n, q = list(map(int, input().split()))
s = list(input())
t_li = []
d_li = []
for i in range(q):
    td = input().split()
    t_li.append(td[0])
    d_li.append(td[1])
n_s = [1 for i in range(n)]
for j in range(q):
    for i in range(n):
        if s[i] == t_li[j]:
            if d_li[j] == "L":
                if i > 0:
                    k = n_s[i]
                    n_s[i] = 0
                    n_s[i - 1] += k
                else:
                    n_s[i] = 0
            else:
                if i < n-1:
                    k = n_s[i]
                    n_s[i] = 0
                    n_s[i + 1] += k
                else:
                    n_s[i] = 0
ans = 0
for i in n_s:
    ans += i
print(ans)
