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
min = -1
max = n
while max-min > 1
    mid = (max+min)/2
    i = mid
    ok = false
    q.times do |j|
        if t[j] == s[i]
            i += (d[j] == "R" ? 1 : -1)
            break if i == n
            if i == -1
                ok = true
                break
            end
        end
    end
    if ok
        min = mid
    else
        max = mid
    end
end
l = min
min = -1
max = n
while max-min > 1
    mid = (max+min)/2
    i = n-1-mid
    ok = false
    q.times do |j|
        if t[j] == s[i]
            i += (d[j] == "R" ? 1 : -1)
            break if i == -1
            if i == n
                ok = true
                break
            end
        end
    end
    if ok
        min = mid
    else
        max = mid
    end
end
puts n-l-2-min