n, q = map(int,input().split())
s = list(input())
sunuke = [input().split() for i in range(q)]
golem = []

for i in range(n):
    golem.append([s[i]]) #[[letter]...]
    


count = 0
for i in range(q):
    for j in range(n):
        if sunuke[i][0] in golem[j] :
            if sunuke[i][1] == "L":
                if j == 0:
                    count += len(golem[0])
                    golem[j].clear()
                

                else:
                    for k in range(len(golem[j])):
                        golem[j-1].append(golem[j][k])
                        golem[j].clear()
                    
        
            else:
                if j == n-1:
                    count += len(golem[n-1])
                  	golem[j].clear()
                    

                else:
                    for k in range(len(golem[j])):
                        golem[j+1].append(golem[j][k])
                        golem[j].clear()

            
   
                    
    


answer = n - count
print(answer)

