import numpy as np
N, Q = list(map(int, input().split()))
s = input()
spells =  [input().split() for i in range(Q)]

spell_dic = {}
for sp_name in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
    spell_dic[sp_name] = np.array([0,0,0])
for sp in spells:
    movecount = spell_dic[sp[0]][0] + (-1 if sp[1] =="L" else +1) #移動カウント
    Lbound = spell_dic[sp[0]][1]
    Rbound = spell_dic[sp[0]][2]
    spell_dic[sp[0]] = np.array([movecount, min(movecount, Lbound), max(movecount, Rbound)])

livecount = 0
for ind , si in enumerate(s):
    sp = spell_dic[si]
    if (ind + sp[1]) >= 0 and (ind +sp[2]) < N:
        livecount +=1
print(livecount)