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

def arrive_left(start_i, tds, s):
    i = start_i
    for t, d in tds:
        if d == 'L' and s[i] == t:
            i -= 1
        if i < 0:
            return True
    return False

def arrive_right(start_i, tds, s, N):
    i = start_i
    for t, d in tds:
        if d == 'R' and s[i] == t:
            i += 1
        if i >= N:
            return True
    return False

i = N // 2
while True:
    if arrive_left(i, tds, S):
        if not arrive_left(i+1, tds, S):
            break
        i = (i + N) // 2
    else:
        if i == 0:
            i = -1
            break
        i = i // 2
arrive_left_i = i

i = N // 2
while True:
    if arrive_right(i, tds, S, N):
        if not arrive_right(i-1, tds, S, N):
            break
        i = i // 2
    else:
        if i == N-1:
            i = N
            break
        i = (i + N) // 2
arrive_right_i = i

arrive_golem = (arrive_left_i + 1) + (N - arrive_right_i)

print(N - arrive_golem)
