def drop?(s,q,pos)
  n=s.size
  q.each{|t,d|
    next unless t==s[pos]
    pos+=d
    if pos<0
      return -1
    elsif pos==n
      return 1
    end
  }
  0
end

n,q=gets.split.map(&:to_i)
s=gets.chomp.chars.map(&:to_sym)
query=q.times.map{
  t,d=gets.split
  sym=t.to_sym
  dir=d==?L ? -1 : 1
  [sym,dir]
}

l_most=-1
l,r=0,n-1
until l>r
  m=(l+r)/2
  if drop?(s,query,m)==-1
    l_most=m
    l=m+1
  else
    r=m-1
  end
end
r_most=n
l,r=0,n-1
until l>r
  m=(l+r)/2
  if drop?(s,query,m)==1
    r_most=m
    r=m-1
  else
    l=m+1
  end
end

puts r_most-l_most-1