# -*- coding: utf-8 -*-
N, Q = map(int, input().split())
s = input()
t = [''] * Q
d = [''] * Q
for i in range(Q):
    t[i], d[i] = input().split()
G = [1] * N
 
for i in range(Q):
    if t[i] == s[0]:
        if d[i] == 'R':
            G[1] += G[0]
            G[0] = 0
        elif d[i] == 'L':
            G[0] = 0

    for j in range(1, N - 1):
        if t[i] == s[j]:
            if d[i] == 'R':
                G[j + 1] += G[j]
                G[j] = 0
            elif d[i] == 'L':
                G[j - 1] += G[j]
                G[j] = 0
                
    if t[i] == s[N - 1]:
        if d[i] == 'R':
            G[N - 1] = 0
        elif d[i] == 'L':
            G[N - 2] += G[N - 1]
            G[N - 1] = 0

print(sum(G))