import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import Math._

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, Q = in.next().toInt
  val s = "0" + in.next()

  val t = new Array[Char](Q+1)
  val d = new Array[String](Q+1)


  for (i <- 1 to Q) {
    val _t, _d = in.next()
    t(i) = _t(0)
    d(i) = _d
  }

  //
  var ans = N

  // 左に落ちるかどうか
  def checkLeft(m: Int): Boolean = {
    var res = false
    var ind = m

    breakable {
      for (q <- 1 to Q) {
        if(s(ind) == t(q)) {
          if (d(q) == "L")
            ind -= 1
          else
            ind += 1
        }

        if (ind <= 0) {
          res = true
          break
        }
        else if(ind > N)
          break
      }
    }

    res
  }

  // 条件を満たす最大の値を返す
  def binarySearchLeft(min: Int, max: Int): Int = {
    val mid: Int = (max + min) / 2
      (max - min) match{
      case 0 | 1 =>
        checkLeft(max) match{
          case true  => max
          case false => min
        }
      case _ =>
        (checkLeft(mid)) match{
          case true  => binarySearchLeft(mid, max)
          case false => binarySearchLeft(min, mid)
        }
    }
  }

  if (checkLeft(1)) {
    val max = binarySearchLeft(1, N)
    ans -= max
  }
  


  ///////////////////////
  // 右に落ちるかどうか
  def check(m: Int): Boolean = {
    var res = false
    var ind = m

    breakable {
      for (q <- 1 to Q) {
        if(s(ind) == t(q)) {
          if (d(q) == "L")
            ind -= 1
          else
            ind += 1
        }

        if (ind <= 0) {
          break
        }
        else if(ind > N){
          res = true
          break
        }
      }
    }

    res
  }


  // 条件を満たす最小の値を返す
  def binarySearch(min: Int, max: Int): Int = {
    val mid: Int = (max + min) / 2
      (max - min) match{
      case 0 | 1 =>
        check(min) match{
          case true  => min
          case false => max
        }
      case _ =>
        (check(mid)) match{
          case true  => binarySearch(min, mid)
          case false => binarySearch(mid, max)
        }
    }
  }

  if (check(N)) {
    val min = binarySearch(1, N)
    ans -= (N - min + 1)
  }




  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}

