import java.util.*
fun main(args: Array<String>) {

    val (N,Q) = readLine()!!.split(" ").map{it.toInt()}
    val s = readLine()!!
    val map = mutableMapOf<Char,MutableList<Int>>()
    for ((i,c) in s.withIndex()) {
        if (map[c] == null) map[c] = mutableListOf()
        map[c]!!.add(i)
    }
    val glm = IntArray(N){1}

    for (q in 0 until Q) {
        val (t, d) = readLine()!!.split(" ").map { it.toCharArray()[0] }
        if (d=='R')
            for (m in map[t]?.reversed()?:continue) {
                if (m + 1 in 0 until N)
                    glm[m + 1] += glm[m]
                glm[m] = 0
            }
        else
            for (m in map[t]?:continue) {
                if (m-1 in 0 until N)
                    glm[m-1] += glm[m]
                glm[m] = 0
            }
    }
    println(glm.sum())
}
