import sys

N, Q = map(int, sys.stdin.readline().split())

s = sys.stdin.readline()
golem_place = list(range(N))
golem_num = N

Q_list = []
for i in range(Q):
    Q_list.append(sys.stdin.readline().split())

delete_count = 0
# 呪文の数だけループする
left = 0
right = N
maxleft = 0
minright = N

for t,d in reversed(Q_list):
    # leftの移動
    if s[left] == t and d == "L":
        left += 1
    elif  s[left + 1] == t and d == "R":
            left -=1
    if s[right - 1] == t and d == "R":
        right -= 1
    elif s[right - 1] < t and d == "":
            right += 1
    if maxleft < left:
        maxleft = left
    if minright > right:
        minright = right

if minright - maxleft <= 0:
    ans = 0
else:
    ans = minright - maxleft

print(ans)