import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
S = input()

query = [input().split() for _ in range(Q)]
res = N

lt = -1
rt = N

while rt - lt > 1:
    mid = (rt + lt) // 2
    pos = mid
    for t, d in query:
        if S[pos] == t:
            if d == 'L':
                pos -= 1
            else:
                pos += 1
            if pos < 0:
                lt = mid
                break
            if pos >= N:
                rt = mid
                break
    else:
        rt = mid

res -= lt + 1

lt = -1
rt = N

while rt - lt > 1:
    mid = (rt + lt) // 2
    pos = mid
    for t, d in query:
        if S[pos] == t:
            if d == 'L':
                pos -= 1
            else:
                pos += 1
            if pos < 0:
                lt = mid
                break
            if pos >= N:
                rt = mid
                break
    else:
        lt = mid

res -= N - rt

print(res)