nq = list(map(int, input().split()))
n = nq[0]
q = nq[1]
s = list(input())
spell = []
for i in range(q):
    si = input().split()
    si = "".join(si)
    spell.append(si)

left_search = 0
right_search = 0
left_count = 0
right_count = 0
left_modori = 0
right_modori = 0
left_charge = 0
right_charge = 0

for i in range(q):
    if len(s) < left_search + left_modori:
        flag1 = False
    else:
        flag1 = True

    if len(s) < right_search + right_modori:
        flag2 = False
    else:
        flag2 = True

    if spell[- i - 1] == s[left_search] + "L":
        if left_modori == 0:
            left_count = left_count + 1
        else:
            left_modori = left_modori - 1
            left_charge = left_charge + 1
            if left_modori == -1:
                left_count = left_count + left_charge
                left_charge = 1
                left_modori = 0
        left_search = left_search + 1
    elif flag1:
        if spell[- i - 1] == s[left_search + left_modori + 1] + "R":
            left_modori = left_modori + 1

    if spell[- i - 1] == s[- right_search - 1] + "R":
        if right_modori == 0:
            right_count = right_count + 1
        else:
            right_modori = right_modori - 1
            right_charge = right_charge + 1
            if right_modori == -1:
                right_count = right_count + right_charge
                right_charge = 1
                right_modori = 0
        right_search = right_search + 1
    elif flag2:
        if spell[- i - 1] == s[- right_search - right_modori - 2] + "L":
            right_modori = right_modori + 1

if left_count + right_count > n:
    print(0)
else:
    print(n - left_count - right_count)