# -*- coding: utf-8 -*-

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

ll, lu, rl, ru = 0, N + 1, 0, N + 1
#while ll != lu and rl != ru:
for i in range(4):
    lp, rp = ll + (lu - ll) // 2, rl + (ru - rl) // 2
    for i in range(Q):
        if s[lp] == TD[i][0]:
            lp = lp + 1 if TD[i][1] == 'R' else lp - 1
        if s[rp] == TD[i][0]:
            rp = rp + 1 if TD[i][1] == 'R' else rp - 1
    if lp == 0:
        ll, lu = ll + (lu - ll) // 2, lu
    else:
        ll, lu = ll, ll + (lu - ll) // 2 - 1
    if rp == N + 1:
        rl, ru = rl, rl + (ru - rl) // 2
    else:
        rl, ru = rl + (ru - rl) // 2, ru

print(N - lu - (N - rl))
