val tdList = mutableListOf<Pair<Char, Char>>()
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))
    }

    var lmax = s.length / 2 //ギリギリ左に落ちない
    var lastPos = calcLastPos(s[lmax], lmax)
    while (true) {
        if (lastPos < 0) {
            lmax++
            lastPos = calcLastPos(s[lmax], lmax)
        } else if (lastPos >= s.length) {
            lmax--
            lastPos = calcLastPos(s[lmax], lmax)
        } else {
            lmax--
            if (lmax == -1) break
            lastPos = calcLastPos(s[lmax], lmax)
            if (lastPos < 0) {
                lmax++
                break
            }
        }
    }
    var rmax = s.length / 2 //ギリギリ右に落ちない
    lastPos = calcLastPos(s[rmax], rmax)
    while (true) {
        if (lastPos < 0) {
            rmax++
            lastPos = calcLastPos(s[rmax], rmax)
        } else if (lastPos >= s.length) {
            rmax--
            lastPos = calcLastPos(s[rmax], rmax)
        } else {
            rmax++
            if (rmax == s.length - 1) break
            lastPos = calcLastPos(s[rmax], rmax)
            if (lastPos >= s.length) {
                rmax--
                break
            }
        }
    }
    println(rmax - lmax + 1)
}

fun calcLastPos(c: Char, start: Int): Int {
    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
            }
    }
    return cur
}