N,Q = map(int,input().split())
S = ' '+input()+' '

Q = tuple(tuple(input().split()) for _ in range(Q))


def simulate(i):
    for t,d in Q:
        if S[i] == t:
            i += 1 if d == 'R' else -1
    return i

def find(ng, ok, judge):
    while abs(ng-ok) > 1:
        m = (ng+ok)//2
        if judge(m):
            ok = m
        else:
            ng = m
    return ok

i_l = find(0, N+1, lambda i: simulate(i) != 0)
i_r = find(N+1, 0, lambda i: simulate(i) != N+1)

print(i_r-i_l+1)