from collections import defaultdict
N, Q = map(int, input().split(' '))
s = input()
s = list(s)
s.insert(0, '0')
s.append('1')
counts = [1 for _ in range(N+2)]

hoge = defaultdict(list)
for i in range(N):
    hoge[s[i]].append(i)
for _ in range(Q):
    t, d = input().split(' ')
    
    if d == 'L':
        for c in hoge[t]:
            counts[c - 1] += counts[c]
            counts[c] = 0
    else:
        for c in hoge[t]:
            counts[c + 1] += counts[c]
            counts[c] = 0
ans = sum(counts[1:N+1])
print(ans)

    
