@n,@q=gets.chomp.split(" ").map{|s| s.to_i}
@s=gets.chomp
@t,@d=[],[]
for i in 0..@q-1
  @t[i],@d[i]=gets.chomp.split(" ")
end
ans=@n

def bs(k)
  for i in 0..@q-1
    if @s[k]==@t[i]
      k+=1 if @d[i]=="R"
      k-=1 if @d[i]=="L"
      return false if k>=@n || k<0
    end
  end
    return true
end

l,r=0,@n

while r-l!=1
  if bs((l+r)/2)
    l=(r+l)/2
  else
    r=(r+l)/2
  end
end
ans-=@n-r
l,r=0,@n

while r-l!=1
  if bs((l+r)/2)
    r=(r+l)/2
  else
    l=(r+l)/2
  end
end
ans-=r
p ans
