N, Q = map(int, input().split())
S = list(str(input()))

uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
s_dic = {uc: set() for uc in uppercase}
for index, s in enumerate(S):
    s_dic[s].add(index)

ans = N
g_list = [1 for i in range(N)]
for _ in range(Q):
    t, d = map(str, input().split())
    for index in s_dic[t]:
        if g_list[index] != 0:
            if d == 'L':
                tmp = g_list[index]
                g_list[index] = 0
                if index == 0:
                    ans -= tmp
                else:
                    g_list[index - 1] += tmp
            else:
                tmp = g_list[index]
                g_list[index] = 0
                if index == N-1:
                    ans -= tmp
                else:
                    g_list[index + 1] += tmp
print(ans)