tokens = input().split(' ')
n = int(tokens[0])
q = int(tokens[1])
s = list(input())

for i in range(q):
    tokens = input().split(' ')
    t = tokens[0]
    d = tokens[1]

    ns = [''] * n
    for j in range(n):
        if not t in s[j]:
            ns[j] += s[j]
            continue
        
        if d == 'L':
            if j != 0:
                ns[j - 1] += s[j]
        else: # d == 'R'
            if j != n - 1:
                ns[j + 1] += s[j]
    s = ns
    
answer = 0
for i in range(n):
    answer += len(s[i])
print(answer)
