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

def test1(i,n,q,s,t,d)
    return false if i == -1
    q.times do |j|
        if s[i] == t[j]
            i += (d[j] == "R" ? 1 : -1)
            return true if i == n
            return false if i == -1
        end
    end
    return true
end

def test2(i,n,q,s,t,d)
    return false if i == -1
    q.times do |j|
        if s[n-1-i] == t[j]
            i += (d[j] == "R" ? -1 : 1)
            return true if i == n
            return false if i == -1
        end
    end
    return true
end

l = (-1..n-1).bsearch{|pos|test1(pos,n,q,s,t,d)}
r = (-1..n-1).bsearch{|pos|test2(pos,n,q,s,t,d)}
puts n-l-r