import numpy as np
n,q= map(int,input().split())
s = list(input())
td = [input().split() for _ in range(q)]
data = {i :[] for i in list(set(s))}
for j,i in enumerate(s):
  data[i].append(j+1)

ans = np.array([0]+[1]*n+[0])

for i in td:
  if i[0] in s:
    temp = ans[data[i[0]]].copy()
    ans[data[i[0]]]=0
    if i[1]=='L':
      ans[np.array(data[i[0]])-1]+=temp
    else:
      ans[np.array(data[i[0]])+1]+=temp
  ans[[0,-1]]=0
  
print(ans[1:-1].sum())
