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

object Main extends App {
  val Array(n, q) = in.readLine.split(" ").map(_.toInt)
  val s = in.readLine.toCharArray

  val op = Iterator.continually(in.readLine)
    .take(q)
    .map(_.split(" ").map(_.head.toInt))
    .toArray
  
  op.foreach(e => e(1) = if(e(1) == 'L') -1 else 1)

  def f(pos:Int):Boolean = {
    @tailrec
    def rec(cnt:Int, pos:Int):Boolean = {
      if(pos < 0 || n <= pos || cnt == q) 0 <= pos && pos < n
      else if(s(pos) == op(cnt)(0)) rec(cnt+1, pos + op(cnt)(1))
      else rec(cnt+1, pos)
    }
    rec(0,pos)
  }

  val left = binarySearch(n,false)
  val right = binarySearch(n,true)

  val ans = right - left
  println(ans)

  def binarySearch(x:Int, bool:Boolean):Int = {
    var left = 0
    var right = x

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