N, Q = map(int, input().split())
s = input()
g = [i for i in range(N)]

for _ in range(Q):
    t, d = input().split()
    new_g = []
    for i in range(len(g)):
        if s[g[i]] == t:
            if d == 'R':
                g[i] += 1

            else:
                g[i] -= 1

        if g[i] >= 0 and g[i] < N:
            new_g.append(g[i])

    g = new_g

print(len(g))
