import sys
input = sys.stdin.readline

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

memo = [[None] * N for _ in range(Q)]

def walk(i_td, pos):
    # print("##", i_td, pos)
    if i_td == Q: return pos
    if pos < 0 or N <= pos: return pos
    if memo[i_td][pos] != None: return memo[i_td][pos]
    #
    ti, di = td[i_td]
    if s[pos] == ti:
        ret = walk(i_td + 1, pos + 2 * int(di == 'R') - 1)
    else:
        ret = walk(i_td + 1, pos)
    #
    memo[i_td][pos] = ret
    return ret

l, r = 0, N
while l < r:
    m = l + (r - l) // 2
    # print("# min", (l, r), m)
    m_to = walk(0, m)
    if m_to < 0:
        l = m + 1
    else:
        r = m
l_min = l

l, r = 0, N
while l < r:
    m = r - (r - l) // 2
    # print("# max", (l, r), m)
    m_to = walk(0, m)
    if N <= m_to:
        r = m - 1
    else:
        l = m
l_max = l

print(l_max - l_min + 1)