N,M=map(int,input().split())
a = input()
k = []
for i in range(M):
  ta,tb=map(str,input().split())
  k.append([ta,tb])
k = k[::-1]
s = 0
t = N-1
c=0
for i, j in k:
  if j == "R" and i == a[t]:
    t-=1
    c+=1
  elif j == "L" and i == a[s]:
    s+=1
  if j == "R" and i == a[s]:
    s-=1
  elif j == "S" and i == a[t]:
    t+=1
    c-=1
  if s+c==N and N!=0:break
if N>1:print(N-s-c)
else: 
  if s+c>1:print(1)
  else:print(0)

