N,Q = map(int,input().split())
S = list(input())
g_place = []
S_n = S
word_num = {}
x = 0
for i in S_n:
        word_num[i] = x
        x+= 1

for s in range(len(S)):
        mark = word_num[S[s]]
        inf = {'mark':mark,'g':1}
        g_place.append(inf)
side_LP = 0
side_RP = s


for _ in range(Q):
        t,d = input().split()
        if t in word_num.keys():
                t = word_num[t]
        d = 1 if d=='R' else -1
        for i in range(len(g_place)):
                if g_place[i]['mark'] == t:
                        if not (((i+d) < side_LP) or ((i+d) > side_RP)):
                                g_place[i+d]['g'] += g_place[i]['g']
                        g_place[i]['g'] = 0
print(sum([i['g'] for i in g_place]))