import numpy as np
from collections import defaultdict
from collections import Counter
from collections import OrderedDict
#key = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
# A = int(input())
N, Q = (int(i) for i in input().split())  
S = input()
t_list = list()
d_list = list()
golem_list = [1] * N
for t in range(Q):
    a, b = (i for i in input().split())  
    t_list.append(a)
    d_list.append(b)
#print(t_list)

index_dict = dict()
for i in range(len(S)): # N
    index_dict.setdefault(S[i], []).append(i)        

#print(index_dict)
#print(golem_list)
for i in range(Q):
    if t_list[i] in index_dict:
        for j in index_dict[t_list[i]]:
            if d_list[i] == 'L':
                if j == 0:
                    golem_list[j] = 0
                else:
                    golem_list[j-1] += golem_list[j]
                    golem_list[j] = 0
            else:
                if j == N-1:
                    golem_list[j] = 0
                else:
                    golem_list[j+1] += golem_list[j]
                    golem_list[j] = 0
                pass
            pass
        pass
    
    pass
print(sum(golem_list))