N, Q = map(int, input().split())
s=list(input())
g = [1] * (N + 2)
for i in range(Q):
    Point, RL = input().split()
    for j in range(len(s)):
        if Point == s[j]:
            if RL=="L":
                g[j] = g[j] + g[j+1]
                g[j+1] = 0
            else:
                g[j+2] = g[j+2] + g[j+1]
                g[j+1] = 0
            g[0] = 0
            g[N+1] = 0
print(sum(g))