def rback(i):
    k = 1
    j = i-1
    m = 2
    while j>=0 and m<=N:
        if A[j]==[S[-m],"R"]:
            k += 1
            m += 1
        j -= 1
    return k
def lback(i):
    k = 1
    j = i-1
    m = 1
    while j>=0 and m<N:
        if A[j]==[S[m],"L"]:
            k += 1
            m += 1
        j -= 1
    return k
N,Q = map(int,input().split())
S = input().strip()
A = [input().split() for _ in range(Q)]
flag1 = 0
flag2 = 0
indR = -1
indL = -1
for i in range(Q-1,-1,-1):
    t,d = A[i]
    if t==S[-1] and d=="R" and flag1==0:
        indR = i
        flag1 = 1
    if t==S[0] and d=="L" and flag2==0:
        indL = i
        flag2 = 1
    if flag1==1 and flag2==1:break
n = 0
m = 0
if indR>=0:
    n = rback(indR)
if indL>=0:
    m = lback(indL)
if n+m<=N:
    print(N-n-m)
else:
    print(0)