from bisect import bisect_right
def rback(i):
    k = 1
    j = i-1
    m = 2
    while j>=0 and m<=N:
        if (S[-m],"R") not in G:break
        ind = bisect_right(G[(S[-m],"R")],j)
        if ind==0:break
        j = G[(S[-m],"R")][ind-1]-1
        k += 1
        m += 1
    return k
def lback(i):
    k = 1
    j = i-1
    m = 1
    while j>=0 and m<N:
        if (S[m],"L") not in G:break
        ind = bisect_right(G[(S[m],"L")],j)
        if ind==0:break
        j = G[(S[m],"L")][ind-1]-1
        k += 1
        m += 1
    return k
N,Q = map(int,input().split())
S = input().strip()
A = [input().split() for _ in range(Q)]
G = {}
for i in range(Q):
    t,d = A[i]
    if (t,d) not in G:
        G[(t,d)] = []
    G[(t,d)].append(i)
k1 = 0
flag1 = 0
k2 = 0
flag2 = 0
cnt = 0
for i in range(Q-1,-1,-1):
    if A[i]==[S[-1],"R"] and flag1==0:
        n = rback(i)
        if n>k1 and n+k2<=N:
            cnt += (n-k1)
            k1 = n
        elif n>k1 and n+k2>N:
            cnt = N
            break
        flag1 = 1
    elif A[i]==[S[0],"L"] and flag2==0:
        n = lback(i)
        if n>k2 and k1+n<=N:
            cnt += (n-k2)
            k2 = n
        elif n>k2 and k1+n>N:
            cnt = N
            break
        flag2 = 1
    if flag1==1 and flag2==1:break
print(N-cnt)