N, Q = map(int, input().split())
s = input()
T, D = [], []
for i in range(Q):
    t, d = input().split()
    T.append(t)
    D.append(d)

dead = 0

#はじめは1~Nに一体ずついる
for i in range(1, N+1):
    pos = i
    for j in range(Q):
        if T[j] == s[i - 1]:
            if D[j] == 'L':
                pos -= 1
                if pos < 1:
                    dead += 1
                    break
            else:
                pos += 1
                if pos > N:
                    dead += 1
                    break
print(N - dead)
