import numpy as np

n, q = list(map(int, input().split()))
s = list(input())
 
qs = np.array([1]*(n+2))
s_dict = {}

for i, s_ in enumerate(s):
    
  if s_ not in s_dict.keys():
    s_dict[s_] = [i+1]
    
  else:
    s_dict[s_] += [i+1]
 
for i in range(q):
  t_, d = input().split()
  
  if t_ in s_dict.keys():
    qs_ = qs.copy()
    s_ = np.array(s_dict[t_])
    
    if d=="L":
      qs_[s_-1]+=qs[s_]
      qs_[s_]-=qs[s_]
      
#       for j in s_:
#         qs_[j-1]+=qs[j]
#         qs_[j]-=qs[j]

    else:
      qs_[s_+1]+=qs[s_]
      qs_[s_]-=qs[s_]
#       for j in s_:
#         qs_[j+1]+=qs[j]
#         qs_[j]-=qs[j]
    qs = qs_
print(sum(qs[1:-1]))