N,Q=map(int,input().split())
S=input()
jumon=[]
for i in range(Q):
  t,d=input().split()
  jumon.append([t,d])
def simu(x):
  j=0
  while 0<=x<N and j<Q:
    if jumon[j][0]==S[x]:
      x+=1 if jumon[j][1]=="R" else -1
    j+=1
  if x==-1:
    return -1
  elif x==N:
    return 1
  else:
    return 0
s=0
t=N-1
while t-s>1:
  u=s+(t-s)//2
  if simu(u)==-1:
    s=u
  else:
    t=u
if s==t:
  p=s if simu(s)==-1 else s-1
else:
  if simu(s)!=-1:
    p=s-1
  elif simu(t)!=-1:
    p=s
  else:
    p=t
s=0
t=N-1
while t-s>1:
  u=s+(t-s)//2
  if simu(u)==1:
    t=u
  else:
    s=u
if s==t:
  q=s if simu(s)==1 else s+1
else:
  if simu(t)!=1:
    q=t+1
  elif simu(s)!=1:
    q=t
  else:
    q=s
print(q-p-1)