N, Q = [int(x) for x in input().split()]
S = input()
TD = []
for _ in range(Q):
    t, d = input().split()
    TD.append((t, d))


def isDead(targetIdx):
    ti = targetIdx
    for t, d in TD:
        if t == S[ti]:
            if d == 'L':
                ti -= 1
                if ti == -1:
                    return True
            else:
                ti += 1
                if ti == N:
                    return True
    return False


l, t, r = 0, N // 2, N - 1

while True:
    l2, t2, r2 = l, t, r
    if isDead(t) == True:
        l, t, r = t, (t + r) // 2, r
    else:
        l, t, r = l, (l + t) // 2, t
    if l2 == l and t2 == t and r2 == r:
        break

L = l
if isDead(L) == False:
    L -= 1

l, t, r = 0, N // 2, N - 1
while True:
    l2, t2, r2 = l, t, r
    if isDead(t) == True:
        l, t, r = l, (l + t) // 2, t
    else:
        l, t, r = t, (t + r) // 2, r
    if l2 == l and t2 == t and r2 == r:
        break
R = r
if isDead(R) == False:
    R += 1

print(R - L - 1)

# print((L, R))
# print([isDead(t) for t in range(N)])
