import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}
import scala.annotation.tailrec

object Main extends App {
  val Array(n, q) = in.readLine.split(" ").map(_.toInt)
  val s = in.readLine
  val op = Iterator.continually(in.readLine)
    .take(q)
    .map(_.split(' ').map(_.head))
    .toArray

  def evalute(pos:Int):Int = {
    def rec(pos:Int, cnt:Int):Int = {
      if(pos < 0 || n <= pos || cnt == q) pos match{
        case p if p < 0 => 0
        case p if 0 <= p && p < n => 1
        case p if n <= p => 2
      }
      else if(s(pos) == op(cnt)(0)) {
        if(op(cnt)(1) == 'L') rec(pos-1, cnt+1)
        else rec(pos+1, cnt+1)
      }
      else rec(pos, cnt+1)
    }
    rec(pos,0)
  }
  
  def binarySearch(x:Int):Int = {
    var left = 0
    var right = n

    @tailrec
    def loop(left:Int, right:Int):Int = {
      if(right - left < 2) left
      else {
        val mid = (left + right) / 2
        if(evalute(mid) <= x) loop(mid,right)
        else loop(left, mid)
      }
    }
    loop(left, right)
  }

  val l = binarySearch(0)
  val r = binarySearch(1)
  debug(l,r)
  val ans = r - l
  println(ans)

  def debug(any:Any*):Unit = {
    if(this.getClass.toString != "class Main$")
      println(any.mkString(" "))
  }
}