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]

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