n, q = map(int,input().split())
s = list(input())
list = []
for i in range(q):
    [t,d] = input().split()
    list.append([t,d])
counter = 0
g_num = [1]* n
g_num.append(0)
g_num.insert(0,0)
for i in range(q):
    for j in range(n):

        str = s[j]
        if list[i][0] == str and g_num[j+1] != 0:
            if list[i][1] == "L":
                g_num[j+1] -= 1
                g_num[j] += 1
            elif list[i][1] == "R":
                g_num[j+1] -= 1
                g_num[j+2] += 1
print(n - g_num[0]+g_num[-1])
