N,Q = map(int,input().split())
S = input()
td = [input().split() for _ in range(Q)]
def solve(i):
    cur = i
    for t,d in td:
        if S[cur] == t:
            cur += 1 if d=='R' else -1
        if cur < 0 or cur >= N:
            return False
    return True
 
def binary_search(ok,ng):
    while abs(ok-ng) >1:
        mid = (ok+ng)//2
        if solve(mid):
            ok = mid
        else:
            ng = mid
    return ok
 
print(max(0,binary_search(-1,N)-binary_search(N,-1)+1))