import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
s = list(input())
td = []
for _ in range(Q):
    ti, di = input().split()
    td.append((ti, 2 * int(di == 'R') - 1))


retire = [None] * Q
l_cnt = r_cnt = 0
for i, (ti, di) in enumerate(reversed(td)):
    if di > 0:
        r_cnt += 1
    else:
        l_cnt += 1
    retire[Q - 1 - i] = (l_cnt, N - r_cnt)


l_a, l_b = 0, min(Q, N)
r_a, r_b = N - min(Q, N), N

while True:
    # print("#", (l_a, l_b), (r_a, r_b))
    if r_b < l_a:
        break
    elif l_a < l_b:
        m = l_a + (l_b - l_a) // 2
    elif r_a < r_b:
        m = r_b - (r_b - r_a) // 2
    else:
        break # !!!
    #
    pos = m
    for i, (ti, di) in enumerate(td):
        # print("##", retire[i][0], pos, retire[i][1])
        if retire[i][0] < pos < retire[i][1]:
            break
        elif s[pos] == ti:
            pos += di
            if pos < 0 or N <= pos: break
    #
    if pos < 0:
        l_a = max(l_a, m + 1)
        r_a = max(r_a, m + 1)
    elif N <= pos:
        l_b = min(l_b, m - 1)
        r_b = min(r_b, m - 1)
    else:
        l_b = min(l_b, m)
        l_a = min(l_a, l_b)
        r_a = max(r_a, m)
        r_b = max(r_a, r_b)

print(max(0, r_b - l_a + 1))