object Main {
  import java.util.Scanner

  implicit class RichScanner(sc: Scanner) {
    def readStrings(n: Int): Array[String] = Array.fill(n) { sc.next() }
    def readInts(n: Int): Array[Int] = Array.fill(n) { sc.nextInt() }
    def readLongs(n: Int): Array[Long] = Array.fill(n) { sc.nextLong() }
    def readLineStrings: Array[String] = sc.nextLine().split(' ')
    def readLineInts: Array[Int] = readLineStrings.map(_.toInt)
    def readLineLongs: Array[Long] = readLineStrings.map(_.toLong)
  }

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def solve(sc: Scanner): Unit = {
    val Array(n, q) = sc.readLineInts
    val s = sc.nextLine()
    val td = Array.fill(q) { val Array(t, d) = sc.readLineStrings; (t.charAt(0), d.charAt(0)) }

    import scala.collection.mutable

    var images: mutable.Set[Int] = mutable.Set.empty[Int]
    td.reverse.foreach { case (t, d) =>
      images = {
        val directlyAbove = images.filter(k => s.charAt(k) != t)
        val moved = {
          if (d == 'L') {
            images.map(_ + 1).filter { k =>
              k != n && s.charAt(k) == t
            }
          } else {
            images.map(_ - 1).filter { k =>
              k != -1 && s.charAt(k) == t
            }
          }
        }
        directlyAbove.union(moved)
      }

      if (d == 'L' && s.head == t) {
        images.add(0)
      } else if (d == 'R' && s.last == t) {
        images.add(n - 1)
      }
    }

    println(n - images.size)
  }
}
