# sys.stdin.readline()
import math
import sys


def decision(s,td,index):
    #index番目の文字が落ちるかどうかを判別
    #右に落ちるときは1，左に落ちるときは-1，落ちないときは0を返す
    global N,Q
    qi = 0
    j = index
    for qi in range(Q):
        if j < 0 or j >= N:
            break
        if s[j] == td[qi][0]:
            if td[qi][1] == 'L':
                j -= 1
            elif td[qi][1] == 'R':
                j += 1
    if j == -1:
        return -1
    elif j == N:
        return 1
    else:
        return 0
 
N,Q = map(int,input().split())
s = sys.stdin.readline()
 
td = [0] * Q
for i in range(Q):
    td[i] = (sys.stdin.readline().split())
    
#td[i][j]:i番目の文字(j=0)と方向(j=1)
    
    
RN = math.ceil(math.log2(N))
#2分探索
left = 0
right = N-1
#右側のボーダー
for i in range(RN):
    mid = int((right+left)/2)
    state = decision(s,td,mid)
    if state < 1:
        left = mid
    else:
        right = mid
    if (right - left) == 1:
        break
if right == N-1 and decision(s,td,right) == 0:
    right += 1
border_r = right
    
left = 0
right = N-1
#左側のボーダー
for i in range(RN):
    mid = int((right+left)/2)
    state = decision(s,td,mid)
    if state > -1:
        right = mid
    else:
        left = mid
    if (right - left) == 1:
        break
if left == 0 and decision(s,td,left) == 0:
    right -= 1
border_l = right
print(border_r-border_l)
 