# -*- coding: utf-8 -*-

N,Q = map(int,input().split())
s=  input()

golem = [1 for i in range(N)]

for i in range(Q):
    t,d = input().split()
    #print(golem)
    for i in range(N):
        if s[i] == t:
            if d == "R" and i+1 < N:
                golem[i+1] += golem[i]
            elif d == "L" and i > 0:
                golem[i-1] += golem[i]
            golem[i] = 0    
    #print(golem)
print(sum(golem))
