import numpy as np

N, Q = map(int, input().split())
s = input()
t = [0 for i in range(Q)]
d = [0 for i in range(Q)]
for i in range(Q):
    t[i], d[i] = input().split()
alpha = {}
for i in range(N):
    if s[i] in alpha.keys():
        alpha[s[i]].append(i)
    else:
        alpha[s[i]] = [i]
gorem = np.array([1 for i in range(N)])

def calc_plus(n):
    return n+1
def calc_minus(n):
    return n-1

for i in range(Q):
    if t[i] in alpha.keys():
        if d[i] == 'L':
            basho = alpha[t[i]]
            if basho[0] != 0:

                newbasho = list(map(calc_minus, basho))
                now = gorem[basho]
                gorem[newbasho] += now
                gorem[basho] -= now

            else:
                newbasho = list(map(calc_minus, basho[1:]))
                now = gorem[basho[1:]]
                gorem[0] = 0
                gorem[newbasho] += now
                gorem[basho[1:]] -= now

        else:
            basho = alpha[t[i]]
            if basho[-1] != N-1:

                newbasho = list(map(calc_plus, basho))
                now = gorem[basho]
                gorem[newbasho] += now
                gorem[basho] -= now

            else:
                newbasho = list(map(calc_plus, basho[:-1]))
                now = gorem[basho[:-1]]
                gorem[-1] = 0
                gorem[newbasho] += now
                gorem[basho[:-1]] -= now
    #print(gorem)
print(sum(gorem))