fun main(args:Array<String>?): Unit {
    val (n, q) = readLine()!!.trim().split(' ').map(String::toInt)
    val s = readLine()!!.trim()
    val order = Array(q) {
        val (c, t) = readLine()!!.trim().split(' ')
        Pair(c.first(), t.first().toDirection())
    }
    val fromLeft = lowerBound(0, n){value ->
        !isDropFromLeft(value, s, order.asIterable())
    }
    val fromRight = lowerBound(0, n){value ->
        isDropFromRight(value, s, order.asIterable())
    }
    println(
            if (fromLeft <= fromRight) fromRight - fromLeft else 0
    )
}
fun isDropFromRight(start: Int, state: String, order: Iterable<Pair<Char, Direction>>): Boolean {
    var current = start
    for ((t, d) in order) if (state[current] == t) {
        when(d){
            Direction.Left -> current--
            Direction.Right -> current++
        }
        if (current !in state.indices) return current > 0
    }
    return false
}
fun isDropFromLeft(start: Int, state: String, order: Iterable<Pair<Char, Direction>>): Boolean {
    var current = start
    for ((t, d) in order) if (state[current] == t){
        when(d){
            Direction.Left -> current--
            Direction.Right -> current++
        }
        if (current !in state.indices) return current < 0
    }
    return false
}
inline fun lowerBound(from: Int, to: Int, predicate: (value: Int) -> Boolean): Int {
    var left = from
    var right = to
    while(left < right){
        val mid = (left + right) / 2
        if (predicate(mid)){
            right = mid
        }else {
            left = mid + 1
        }
    }
    return right
}
fun Char.toDirection(): Direction {
    return when(this){
        'L' -> Direction.Left
        'R' -> Direction.Right
        else -> throw Exception()
    }
}
enum class Direction{
    Left, Right
}