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)

final_idxes = {}
def get_final_idx(i):
    if final_idxes.get(i, None) != None:
        return final_idxes[i]

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

        d = d_list[j]
        if d == 'L':
            tmp_i -= 1
        else:
            tmp_i += 1

        if tmp_i in (-1, N):
            break

    final_idxes[i] = tmp_i
    return tmp_i

# 2分探索にして計算量を減らす
golem_size = N
low = -1
high = N
while high - low > 1:
    mid = (low + high) // 2
    final_idx = get_final_idx(mid)
    if final_idx == -1:
        low = mid
    else:
        high = mid

golem_size -= high

low = -1
high = N
while high - low > 1:
    mid = (low + high) // 2
    final_idx = get_final_idx(mid)
    if final_idx == N:
        high = mid
    else:
        low = mid

golem_size -= (N - 1 - low)

print(golem_size)