import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val spellCount = sc.nextInt()
    val strings = sc.next().map { it.toString() }
    val golems = strings.mapIndexed { index, s -> Golem(s, index) }
    val spells = parseList(sc, spellCount)
    val result = callSpell(spells, golems, strings, n)
    println("${result.size}")
}

private fun parseList(scanner: Scanner, length: Int): List<Spell> {
    return (0 until length).map {
        val s = scanner.next()
        val toR = scanner.next() == "R"
        Spell(s, toR)
    }
}

private tailrec fun callSpell(spells: List<Spell>, golems: List<Golem>, strings: List<String>, limit: Int): List<Golem> {
    if (spells.isEmpty()) {
        return golems
    }
    val spell = spells.first()
    val newGolems = golems.mapNotNull { golem ->
        if (spell.s == golem.s) {
            // 動く
            val forward = if (spell.toRight) 1 else -1
            golem.position += forward
            if (golem.position < 0 || golem.position >= limit) {
                // はみ出た
                return@mapNotNull null
            }
            // 文字変更
            golem.s = strings[golem.position]
            golem
        } else {
            // 対象外
            golem
        }
    }
    return callSpell(spells.takeLast(spells.size - 1), newGolems, strings, limit)
}

data class Spell(val s: String, val toRight: Boolean)

data class Golem(var s: String, var position: Int)
