package main

import (
  "fmt"
  "os"
  "io"
)

func solve(w io.Writer, r io.Reader) {
  var N, Q int
  var s string
  fmt.Fscan(r, &N, &Q, &s)

  m := make(map[rune][]int)

  for i, v := range s {
    m[v] = append(m[v], i)
  }

  c := N
  for i := 0; i < Q; i++ {
    var ts, ds string
    fmt.Fscan(r, &ts, &ds)
    t, d := rune(ts[0]), rune(ds[0])
    var tmp []int
    for _, k := range m[t] {
      p := -1
      if d == 'L' {
        if k > 0 {
          p = k - 1
        } else {
          c--
        }
      } else {
        if k < N-1 {
          p = k + 1
        } else {
          c--
        }
      }
      if p != -1 {
        q := rune(s[p])
        if q == t {
          tmp = append(tmp, p)
        } else {
          m[q] = append(m[q], p)
        }
      }
    }
    m[t] = tmp    
  }
  fmt.Fprint(w, c)
}

func main() {
  solve(os.Stdout, os.Stdin)
}