val tdList = mutableListOf<Pair<Char, Char>>()
val map = mutableMapOf<Pair<Char, Int>, Int>()
var s = ""
fun main(args: Array<String>) {
    val (n, q) = readLine()!!.split(' ').map(String::toLong)
    s = readLine()!!
    (1..q).forEach {
        val (t, d) = readLine()!!.split(' ').map { it[0] }
        tdList.add(Pair(t, d))
    }
    val lmax = l(0, s.length - 1)//ギリギリ左に落ちない
    val rmax = r(0, s.length - 1)//ギリギリ左に落ちない
    println(rmax - lmax + 1)
}

fun l(left: Int, right: Int): Int {
    val center = (right + left) / 2
    val lastPos = calcLastPos(s[center], center)
    if (lastPos < 0) {
        if (calcLastPos(s[center + 1], center + 1) >= 0) return center + 1
        return l((left + right) / 2, right)
    } else if (lastPos >= s.length) {
        return l(left, (left + right) / 2)
    } else {
        if (center == 0) return 0
        if (calcLastPos(s[center - 1], center - 1) < 0) return center
        return l(left, (left + right) / 2)
    }
}

fun r(left: Int, right: Int): Int {
    val center = (right + left) / 2 + if ((right + left) % 2 == 1) 1 else 0
    val lastPos = calcLastPos(s[center], center)
    if (lastPos < 0) {
        return r((left + right) / 2, right)
    } else if (lastPos >= s.length) {
        if (calcLastPos(s[center - 1], center - 1) < s.length) return center - 1
        return r(left, (left + right) / 2)
    } else {
        if (center == s.length - 1) return s.length - 1
        if (calcLastPos(s[center + 1], center + 1) >= s.length) return center
        return r((left + right) / 2, right)
    }
}

fun calcLastPos(c: Char, start: Int): Int {
    if (map.containsKey(Pair(c, start))) return map[Pair(c, start)]!!
    var cur = start
    tdList.forEach {
        if (cur >= 0 && cur < s.length) {
            cur += if (it.first == s[cur] && it.second == 'L') {
                -1
            } else if (it.first == s[cur] && it.second == 'R') {
                1
            } else {
                0
            }
        } else {
            return@forEach
        }
    }
    map[Pair(c, start)] = cur
    return cur
}