N, Q = map(int, input().split())
S = input()
G = []
T = []
D = []

for i in range(Q):
    T.append(input())

for i in range(N):
    G.append(1)

for i in range(Q):
    for ii in range(N):
        if T[i][0] == S[ii]:
            if T[i][2] == "L":
                if ii != 0:
                    G[ii - 1] += G[ii]
                G[ii] = 0
            
            else:
                if ii != N - 1:
                    G[ii + 1] += G[ii]
                G[ii] = 0
count = 0
for i in range(N):
    count += G[i]

print(count)