from collections import Counter

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

if n == 1:
    for t, d in td:
        if s[0] == t:
            print(0)
            exit()
    print(1)
    exit()

def vanish(x):
    for t, d in td:
        if s[x] == t:
            if d == 'L':
                x -= 1
                if x == -1:
                    return -1
            else:
                x += 1
                if x == n:
                    return n
    return x

L = 0
R = n
U = 0
ans = n

while R - L > 1:
    M = (L + R) // 2
    ret = vanish(M)
    if ret == -1:
        L = M
    else:
        R = M

ret = vanish(L)
if ret == -1:
    ans -= L + 1
else:
    ans -= L

L = 0
R = n

while R - L > 1:
    M = (L + R) // 2
    ret = vanish(M)
    if ret == n:
        R = M
    else:
        L = M

ret = vanish(L)
if ret == n:
    ans -= n - L
else:
    ans -= n - 1 - L

print(ans)


