n, q = map(int, input().split())
s = "_{}_".format(input())
spells = [input().split() for _ in range(q)]

current_l = 0
current_r = n + 1

for t, d in reversed(spells):

    if t == s[current_l + 1] and d == "L":
        current_l += 1
    elif t == s[current_l - 1] and d == "R":
        current_l -= 1

    if t == s[current_r - 1] and d == "R":
        current_r -= 1
    elif t == [current_r + 1] and d == "L":
        current_r += 1

print(max(current_r - current_l - 1, 0))
