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
a = 0
b = n
t.each_with_index do |c,i|
    if d[i] == "L"
        l += 1 if s[l] == c
        r += 1 if r < n-1 && s[r+1] == c
    else
        l -= 1 if l > 0 && s[l-1] == c
        r -= 1 if s[r] == c
    end
    if l > r
        l = q
        r = 0
    end
    a = l if a < l
    b = r if b > r
end
puts [0,b-a+1].max