n,q=map(int,input().split())
s=input()
places=[]
moves=[]
for _ in range(q):
  p,m=map(str,input().split())
  places.append(p)
  moves.append(m)
l=-1
r=n
while r-l!=1:
  mid=(l+r)//2
  p=mid
  for i in range(q):
    if s[p]==places[i]:
      if moves[i]=='L':
        p-=1
      if moves[i]=='R':
        p+=1
      if p<0 or p>=n:
        l=mid
        break
  else:
    r=mid
remain_left=r
l=remain_left
r=n
while r-l!=1:
  mid=(l+r)//2
  p=mid
  for i in range(q):
    if s[p]==places[i]:
      if moves[i]=='L':
        p-=1
      if moves[i]=='R':
        p+=1
      if p<0 or p>=n:
        r=mid
        break
  else:
    l=mid
remain_right=l
print(remain_right-remain_left+1)