fun main(args: Array<String>) {
    val (n,q) = readLine()!!.split(" ").map{it.toInt()}
    val s =readLine()!!
    val td = Array(q){readLine()!!.split(" ").map { s->s[0] }}
    var min = 0
    var max = n-1
    for(i in q-1 downTo 0){
        if(min>max)break

        if(td[i][1]=='L'){
            if(s[min]==td[i][0]){
                min+=1
            }
            if(max<n-1&&s[max+1]==td[i][0]){
                max+=1
            }
        }else {
            if(s[max]==td[i][0]){
                max-=1
            }
            if(0<min&&s[min-1]==td[i][0]){
                min-=1
            }
        }

    }
    print(Math.max(max-min+1,0))
}