import math

N, Q = map(int, input().split())
s = input()

t_list = []
d_list = []
for _ in range(Q):
    t, d = input().split()
    t_list.append(t)
    d_list.append(d)

def get_final_idx(i):
    for j in range(Q):
        tmp_s = s[i]
        t = t_list[j]
        if t != tmp_s:
            continue

        d = d_list[j]
        if d == 'L':
            if i == 0:
                return -1
            i -= 1
        else:
            if i == N - 1:
                return N
            i += 1

    return i

# 2分探索にして計算量を減らす
golem_size = N
for i in range(math.floor(N / 2), -1, -1):
    final_i = get_final_idx(i)
    if final_i == -1:
        golem_size -= i + 1
        break

for i in range(math.floor(N / 2) + 1, N):
    final_i = get_final_idx(i)
    if final_i == N:
        golem_size -= (N - i)
        break

print(golem_size)