N,Q = map(int,input().split())
s = list(input())
move = []
onehot = [1]*N
for i in range(Q):
    t,d = input().split()
    move.append([t,d])
#print(move)
for i in range(Q):
    for j in range(N):
        if move[i][0] == s[j]:
            if move[i][1] == "L":
                if onehot[j] > 0:
                    if j-1 >= 0:
                        onehot[j-1] += onehot[j]
                    onehot[j] = 0
            elif move[i][1] == "R":
                if onehot[j] > 0:
                    if j+1 < N:
                        onehot[j+1] += onehot[j]
                    onehot[j] = 0
                
#print(onehot)
print(sum(onehot))