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

ans = N
g_list = [1 for i in range(N)]
for _ in range(Q):
    t, d = map(str, input().split())
    for index, s in enumerate(S):
        if s == 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)