import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
s = list(input())
td = [input().split() for _ in range(Q)]

ans_ll = pos_ll = -1
ans_lr = pos_lr = 0
for ti, di in reversed(td):
    # print("## l", pos_ll, pos_lr)
    if ti == s[pos_ll + 1] and di == 'L':
        pos_ll += 1
    elif pos_ll < 1:
        pass
    elif ti == s[pos_ll - 1] and di == 'R':
        pos_ll -= 1
    if ans_ll < pos_ll: ans_ll = pos_ll
    #
    if ti == s[pos_lr + 1] and di == 'L':
        pos_lr += 1
    elif pos_lr < 1:
        pass
    elif ti == s[pos_lr - 1] and di == 'R':
        pos_lr -= 1
    if ans_lr < pos_lr: ans_lr = pos_lr

ans_rl = pos_rl = N - 1
ans_rr = pos_rr = N
for ti, di in reversed(td):
    # print("## r", pos_rl, pos_rr)
    if ti == s[pos_rr - 1] and di == 'R':
        pos_rr -= 1
    elif pos_rr > N - 1:
        pass
    elif ti == s[pos_rr + 1] and di == 'L':
        pos_rr += 1
    if ans_rl > pos_rl: ans_rl = pos_rl
    #
    if ti == s[pos_rl - 1] and di == 'R':
        pos_rl -= 1
    elif pos_rl > N - 1:
        pass
    elif ti == s[pos_rl + 1] and di == 'L':
        pos_rl += 1
    if ans_rr > pos_rr: ans_rr = pos_rr

# print("#", ans_ll, ans_lr, ans_rl, ans_rr)

l, r = ans_ll, ans_lr + 1
while l < r:
    m = l + (r - l) // 2
    # print("# min", (l, r), m)
    m_tmp = m
    for i, (ti, di) in enumerate(td):
        if s[m_tmp] == ti:
            m_tmp += (1 if di == 'R' else -1)
        if m_tmp < 0 or N <= m_tmp:
            break
    if m_tmp < 0:
        l = m + 1
    else:
        r = m
l_min = l
 
l, r = ans_rl - 1, ans_rr
while l < r:
    m = l + (r - l + 1) // 2
    # print("# max", (l, r), m)
    m_tmp = m
    for i, (ti, di) in enumerate(td):
        if s[m_tmp] == ti:
            m_tmp += (1 if di == 'R' else -1)
        if m_tmp < 0 or N <= m_tmp:
            break
    if N <= m_tmp:
        r = m - 1
    else:
        l = m
l_max = l
 
print(l_max - l_min + 1)