# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


class RollingHash:
    def __init__(self, s, base, mod):
        self.s = s
        self.length = length = len(s)
        self.base = base
        self.mod = mod
        self.h = h = [0] * (length + 1)
        for i in range(length):
            h[i + 1] = (h[i] * base + ord(s[i])) % mod
        self.p = p = [1] * (length + 1)
        for i in range(length):
            p[i + 1] = pow(base, i + 1, mod)

    def get(self, l, r):
        mod = self.mod
        # return (self.h[r] - self.h[l] * pow(self.base, r - l, mod) + mod) % mod
        return ((self.h[r] - self.h[l] * self.p[r - l]) + mod) % mod


def main():
    n, q = LI()
    S = SI()

    B = [LS() for _ in range(q)]
    L, R = [], []
    for t, d in B:
        if d == 'L':
            L.append(t)
        else:
            R.append(t)

    cnt = 0
    i, b = len(L) - 1, 0
    while i >= 0 and b < n:
        if S[b] == L[i]:
            cnt += 1
            b += 1
        i -= 1

    i, bb = len(R) - 1, n - 1
    while i >= 0 and bb >= 0:
        if S[bb] == R[i]:
            cnt += 1
            bb -= 1
        i -= 1

    return max(0, n - cnt)


print(main())
