fun main(args: Array<String>) {
    val (n, q) = readLine()!!.split(" ").map(String::toInt)
    val s = readLine()!!
    val qs = Array(q) { readLine()!!.split(" ") }

    val golemCounts = IntArray(s.count()) { 1 }

    val map = mutableMapOf<Char, MutableList<Int>>()
    for (i in 0..s.length - 1) {
        val c = s[i]
        if (map[c] == null) {
            map[c] = mutableListOf(i)
        } else {
            map[c]!!.add(i)
        }
    }

    for ((t, d) in qs) {
        move(map, golemCounts, t[0], d[0])
    }
    println(golemCounts.sum())
}


private fun move(map: Map<Char, List<Int>>, golemCounts: IntArray, t: Char, d: Char) {
    if (map[t] == null) {
        return
    }

    val positions = if (d == 'L') {
        map[t]!!
    } else {
        map[t]!!.reversed()
    }

    positions.forEach { pos ->
        val golemNum = golemCounts[pos]
        if (golemNum > 0) {
            golemCounts[pos] = 0
            if (d == 'L' && pos > 0) {
                golemCounts[pos - 1] += golemNum
            } else if (d == 'R' && pos + 1 < golemCounts.size) {
                golemCounts[pos + 1] += golemNum
            }
        }

    }
}