def decision(s,td,index):
    #index番目の文字が落ちるかどうかを判別
    #右に落ちるときは1，左に落ちるときは-1，落ちないときは0を返す
    global N,Q
    qi = 0
    j = index
    while qi < Q and (j >= 0 and j < N):
        if s[j] == td[qi][0]:
            if td[qi][1] == 'L':
                j -= 1
            elif td[qi][1] == 'R':
                j += 1
        qi += 1
    if j == -1:
        return -1
    elif j == N+1:
        return 1
    else:
        return 0
    


N,Q = map(int,input().split())
s = input()

td = [0] * Q
for i in range(Q):
    td[i] = (input().split())
    
#td[i][j]:i番目の文字(j=0)と方向(j=1)
    
    
#2分探索
left = 0
right = N-1
#右側のボーダー
while (right - left ) != 1:
    mid = round((right+left)/2)
    state = decision(s,td,mid)
    if state < 1:
        left = mid
    else:
        right = mid
if right == N-1:
    right += 1
border_r = right
    
left = 0
right = N-1
#左側のボーダー
while (right - left ) != 1:
    mid = round((right+left)/2)
    state = decision(s,td,mid)
    if state > -1:
        right = mid
    else:
        left = mid
if right == 0:
    right -= 1
border_l = right
print(border_r-border_l)

