import sys
input = sys.stdin.readline
n, q = map(int, input().split())

s = list(input())

td_lis = [input().split() for i in range(q)]

g_lis = [['', 0]]
for i in range(n):
    g_lis.append([s[i], 1])
g_lis.append(['', 0])


for i in range(q):
    for j in range(n+2):
        if(g_lis[j][0] == td_lis[i][0] and g_lis[j][1] > 0):
            if(td_lis[i][1] == 'L'):
                g_lis[j-1][1] += g_lis[j][1]
                g_lis[j][1] = 0
            else:
                g_lis[j+1][1] += g_lis[j][1]
                g_lis[j][1] = 0


sum = 0
for i in range(1, n+1):
    sum += g_lis[i][1]

print(sum)
