N, Q = map(int, input().split())
s = input()
command = [input().split() for i in range(Q)]

def isOK(idx, dst):
    for c, direction in command:
        if s[idx] == c:
            if direction == "R":
                idx += 1
            else:
                idx -= 1
        if idx == dst:
            return True
    return False

def bisection(dst):
    ng = N + (-1) - dst
    ok = dst
    while(abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if isOK(mid, dst) :
            ok = mid
        else :
            ng = mid

    return ok

right = bisection(-1)
left = bisection(N)
if left <= right:
    print(0)
else:
    print(N - (N - left) - (right + 1))