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

def simulate(n):
    if n == -1:
        return -1
    elif n == N:
        return 1
    for t, d in TD:
        if t == s[n]:
            if d == 'L':
                n -= 1
            else:
                n += 1
        if n == -1:
            return -1
        elif n == N:
            return 1
    return 0

low = -1
high = N
# 左端を調べる
while low + 1 < high:
    mid = (low + high) // 2
    if simulate(mid) == -1:
        low = mid
    else:
        high = mid
L = low

low = -1
high = N
# 右端を調べる
while low + 1 < high:
    mid = (low + high) // 2
    if simulate(mid) == 1:
        high = mid
    else:
        low = mid
H = high

print(H-L-1)
