n,q = gets.split.map(&:to_i)
s = gets.chomp
t,d = 2.times.map{Array.new(q)}
q.times do |i|
    t[i],d[i] = gets.chomp.split
end
t.reverse!
d.reverse!
l = 0
r = n-1
t.each_with_index do |c,i|
    l += 1 if s[l] == c && d[i] == "L"
    r -= 1 if s[r] == c && d[i] == "R"
    if l > r
        l = q
        r = 0
    end
end
puts [0,r-l+1].max