# coding: utf-8
# Your code here!

import random
from collections import defaultdict
import sys
sys.setrecursionlimit(int(1e6))

N, Q = map(int, input().rstrip().split(' '))
X = [x for x in input()]

type_char = [x for x in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']
X_char2ids = dict([(x, []) for x in type_char])
ope_char2ids = dict([(x, []) for x in type_char])
operations = []

for i in range(Q):
    t, d = input().rstrip().split(' ')
    operations.append([t, d])
    ope_char2ids[t].append(i)
   
#memo = [[-1] * (Q + 1) for _ in range(N)]
memo = defaultdict(lambda: defaultdict(lambda: -1))
def recursive(location, count_operation):
    if memo[location][count_operation] != -1:
        return memo[location][count_operation]
    if count_operation >= Q:
        return True
    #if Q - count_operation < min(location, N - location):
    #    return True
        
    exist = True
    for id in ope_char2ids[X[location]]:
        if id >= count_operation:
            if operations[id][1] == 'R':
                if location == N - 1:
                    memo[location][count_operation] = 0
                    exist = False
                    break
                else:
                    exist = recursive(location + 1, id + 1)
                    break
            else:
                if location == 0:
                    memo[location][count_operation] = 0
                    exist = False
                    break
                else:
                    exist = recursive(location - 1, id + 1)
                    break
                
    memo[location][count_operation] = exist
    
    return exist
    

count_exist = 0
for i in range(N):
    count_exist += recursive(i, 0)
    
print(count_exist)

                