import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
s = input().rstrip()
queries = [tuple(input().rstrip().split()) for _ in range(Q)]
lb, ub = 0, N
while ub - lb > 1:
    m = (lb + ub) // 2
    i = m
    ok = False
    for t, d in queries:
        if s[i] == t:
            i += [-1, 1][d == 'R']
        if i == -1:
            ok = True
            break
        if i == N:
            break
    if ok:
        lb = m
    else:
        ub = m
l = lb
lb, ub = 0, N
while ub - lb > 1:
    m = (lb + ub) // 2
    i = m
    ok = False
    for t, d in queries:
        if s[i] == t:
            i += [-1, 1][d == 'R']
        if i == -1:
            break
        if i == N:
            ok = True
            break
    if ok:
        ub = m
    else:
        lb = m
r = ub
print(r - l - 1)