# -*- coding: utf-8 -*-

nq = list(map(int,input().split()))
s = input()
td = []
for i in range(nq[1]):
    td.append(input().split())

g_list = [1] * nq[0]

for i in range(0, nq[1]):
    for j in range(0, nq[0]):
        if td[i][0] == s[j]:
            if td[i][1] == 'R':
                if j != nq[0] -1:
                    g_list[j+1] += g_list[j]
                g_list[j] = 0
            else:
                if j != 0:
                    g_list[j-1] += g_list[j]
                g_list[j] = 0
#    print(g_list)

print(sum(g_list))