[N, Q] = list(map(int, input().split()));
s = list(input());
b = [1] * N;

for q in range(Q):
    [text, dir] = input().split();
    for index in range(N):
        st = s[index];
        if st == text:
            if dir == "L" and index > 0:
                b[index - 1] += b[index];
            elif dir == "R" and index < N-1:
                b[index + 1] += b[index];
            b[index] = 0;
print(sum(b));