# encoding: utf-8
import sys
input = sys.stdin.readline

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

l, r = 0, N
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 = 0, N
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)