import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

N, Q = nm()
board = ns()
assert len(board) == N
spells = []
for i in range(Q):
    t, d = ns().split()
    spells.append((t, d))


def solve():
    head, tail = -1, N
    for i in range(Q - 1, -1, -1):
        if head + 1 >= tail:
            break
        t, d = spells[i]
        if t == board[head + 1] and d == "L":
            head += 1
        if t == board[tail - 1] and d == "R":
            tail -= 1
    return max(tail - head - 1, 0)


print(solve())
