import re

N, Q = [int(item) for item in re.split(r"\s", input())]
s = input()
t = []
d = []
for _ in range(Q):
    t_in, d_in = [item for item in re.split(r"\s", input())]
    t.append(t_in)
    d.append(d_in)


def check(i, LR):
    """Return False when drop

    Args:
        i ([type]): [description]
    """

    for q in range(Q):
        if t[q] == s[i]:
            if d[q] == "L":
                i -= 1
            if d[q] == "R":
                i += 1

            if LR == "L" and i < 0 or LR == "R" and i > N-1:
                return False
    return True


s_index = 0  # include
e_index = N-1  # include
while e_index-s_index >= 2:
    c_index = (e_index-s_index+1)//2+s_index  # center or +1
    if check(c_index, "L"):
        # doesn't drop
        e_index = c_index
    else:
        s_index = c_index

pat1, pat2 = check(s_index, "L"), check(e_index, "L")
if pat1:
    left = s_index-1
elif pat2:
    left = s_index
else:
    left = e_index


s_index = 0  # include
e_index = N-1  # include
while e_index-s_index >= 2:
    c_index = (e_index-s_index+1)//2+s_index  # center or +1
    if check(c_index, "R"):
        # doesn't drop
        s_index = c_index
    else:
        e_index = c_index

pat1, pat2 = check(s_index, "R"), check(e_index, "R")
if pat2:
    right = e_index+1
elif pat1:
    right = e_index
else:
    right = s_index

print(right-left-1)
