N, Q = map(int, input().split())
s = input()
t, d = zip(*(input().split() for _ in range(Q)))


def f(i):
    i -= 1
    if i < 0:
        return -1
    if i >= N:
        return 1
    for j in range(Q):
        if s[i] == t[j]:
            i += 1 if d[j] == 'R' else -1
        if i < 0:
            return -1
        elif i >= N:
            return 1
    return 0


h, l = N + 1, 1
while h > l + 1:
    i = (h + l) // 2
    r = f(i)
    if r == 1:
        h = i
    else:
        l = i

ans = N - h + 1

h, l = N, 0
while h > l + 1:
    i = (h + l) // 2
    r = f(i)
    if r == -1:
        l = i
    else:
        h = i

ans = N - ans - l

print(ans)