N,Q = map(int,input().split())
S = input()
TD = [input().split() for _ in [0]*Q]

def f(n):
    s = S[n]
    for t,d in TD:
        if s==t:
            if d=="L":
                n -= 1
            else:
                n += 1
            if n<0 or N<=n: break
            s = S[n]
    return n

def binary_search(l,r,func):
    if func(l):return l-1
    if not func(r):return r
    while l+1<r:
        i = (l+r)//2
        if func(i):
            r = i
        else:
            l = i
    return l

l = binary_search(0,N-1,lambda n:f(n)>=0)
r = binary_search(0,N-1,lambda n:f(n)>=N)
print(r-l)