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

ts,ds = [None]*Q, [None]*Q
for i in range(Q):
    ts[i], ds[i] = input().split()

def getFinalPos(pos):
    for t, d in zip(ts, ds):
        if s[pos]==t:
            if d=='L':
                pos -= 1
            else:
                pos += 1
    return pos


def b_search(l, nr, t):
    if abs(nr - l) <= 1:
        return l
    mid = (nr + l) // 2
    if getFinalPos(mid) == t:
        return b_search(mid, nr, t)
    else:
        return b_search(l, mid, t)

l = b_search(0, N+2, 0)
nr = b_search(N+1, 0, N+1)

print(nr - 1 - l)
