n, q = io.read("*n", "*n", "*l")
s = io.read()
t = {}
num = {}
for i = 1, n do
    a = string.sub(s, i, i)
    if(t[a] == nil) then
        t[a] = {{}, {}}
    end
    table.insert(t[a][1], i)
    table.insert(t[a][2], 1, i)
    num[i] = 1
end

for i = 1, q do
    tgt, zz, way = io.read(1, 1, "*l")
    if(way == "L") then
        if(t[tgt] ~= nil) then
            for k, v in pairs(t[tgt][1]) do
                if(1 < v) then
                    num[v - 1] = num[v - 1] + num[v]
                end
                num[v] = 0
            end
        end
    else
        if(t[tgt] ~= nil) then
            for k, v in pairs(t[tgt][2]) do
                if(v < n) then
                    num[v + 1] = num[v + 1] + num[v]
                end
                num[v] = 0
            end
        end
    end
end
sum = 0
for i = 1, n do
    sum = sum + num[i]
end
print(sum)