from sys import stdin
from bisect import bisect_left as bl, bisect_right as br

n, q = map(int, raw_input().strip().split())
s = raw_input().strip()

moves = [[] for i in xrange(26)]
dead = [-1 for i in xrange(q)]

inp = stdin.readlines()
ctr = 0
for line in inp:
    t, d = line.strip().split()
    nd = -1 if d == 'L' else 1
    moves[ord(t) - 65].append([ctr, nd])
    ctr += 1

ans = n
i = 0
while 1:
    cur = s[i] # current character
    if len(moves[ord(cur) - 65]) == 0: break
    start, move = moves[ord(cur) - 65][0] # starting point (query number), where to move
    pos = i
    qidx = start
    flag = 0
    while 1:
        if pos == dead[qidx]:
            flag = 1
            break
        
        pos = pos + move
        if pos < 0 or pos >= n:
            flag = 1
            break
        cur = s[pos]
        move_idx = bl(moves[ord(cur) - 65], [qidx, 1])
        if move_idx >= len(moves[ord(cur) - 65]): break
        qidx, move = moves[ord(cur) - 65][move_idx]
        
    if flag == 1:
        dead[start] = i
        i += 1
    else:
        break
    if i >= n: break

ans -= i
j = i

if ans == 0:
    print ans
    exit()

i = n - 1
while 1:
    cur = s[i] # current character
    if len(moves[ord(cur) - 65]) == 0: break
    start, move = moves[ord(cur) - 65][0] # starting point (query number), where to move
    pos = i
    qidx = start
    flag = 0
    while 1:
        if dead[qidx] == 1:
            flag = 1
            break
        
        pos = pos + move
        if pos < 0 or pos >= n:
            flag = 1
            break
        cur = s[pos]
        move_idx = bl(moves[ord(cur) - 65], [qidx, 1])
        if move_idx >= len(moves[ord(cur) - 65]): break
        qidx, move = moves[ord(cur) - 65][move_idx]
        
    if flag == 1:
        dead[start] = 1
        i -= 1
    else:
        break
    if i >= n: break
    if i == j: break

killed = n - 1 - i
ans -= killed

print ans