n,q = map(int,input().split())
s = list(input())
point = []
mark = []
for i in range(n):
     if s[i] in mark:
          point[mark.index(s[i])].append(i)
     else:
          mark.append(s[i])
          point.append([i])

g = [0] + [1]*n +[0]

def f(j,o,g):
     if o == "L":
          if g[j] > 0:
               g[j-1] += g[j]
               g[j] = 0
     if o == "R":
          if g[j] > 0:
               g[j+1] += g[j]
               g[j] = 0
     return g
               
     

for i in range(q):
     al,o = map(str,input().split())
     if al in mark:
          for j in point[mark.index(al)]:
               g = f(j+1,o,g)
          
g[0],g[-1] = 0,0
print(sum(g))