import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n,q=map(int,input().split())
s=[None]+list(input())+[None]
L=[tuple(input().split()) for _ in range(q)]

def judge(k):
    now=k
    if now==0:
        return 1
    if now==n+1:
        return 2
    for t,d in L:
        if s[now]==t:
            if d=='R':
                now+=1
            else:
                now-=1
        if now==0:
            return 1
        elif now==n+1:
            return 2
    else:
        return 0

left,right=0,n+1
while right-left>1:
    mid=(left+right)//2
    if judge(mid)==1:
        left=mid
    else:
        right=mid
out=left
left,right=0,n+1
while right-left>1:
    mid=(left+right)//2
    if judge(mid)==2:
        right=mid
    else:
        left=mid
out+=(n+1-right)
print(n-out)