n, q = map(int, input().split())
s = input()
lr = {}
g = [1]*n
def move(x):
    return [-1, 1][x=='R']

for i in s:
    if i not in lr:
        lr[i] = []
        
for i in range(n):
    lr[s[i]].append(i)

for i in range(q):
    a, b = input().split()
    if a in s:
        for k in lr[a]:
            if k+move(b)<0 or n-1<k+move(b):
                g[k] = 0
            else:
                g[k+move(b)] += g[k]
                g[k] = 0

print(sum(g))
