package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	nq := nextIntArray()
	n, q := nq[0], nq[1]

	s := nextLine()

	count := make([]int, 'Z'-'A'+3)
	for _, v := range s {
		count[v-'A']++
	}

	// 左 'Z'-'A'+1 右 'Z'-'A'+2
	gr := make([][]int, 'Z'-'A'+3)
	for i := 0; i < 'Z'-'A'+3; i++ {
		gr[i] = make([]int, 'Z'-'A'+3)
	}
	gr[s[len(s)-1]-'A']['Z'-'A'+2]++

	gl := make([][]int, 'Z'-'A'+3)
	for i := 0; i < 'Z'-'A'+3; i++ {
		gl[i] = make([]int, 'Z'-'A'+3)
	}
	gl['Z'-'A'+1][s[0]-'A']++

	for i := 1; i < n; i++ {
		gl[s[i]-'A'][s[i-1]-'A']++
		gr[s[i-1]-'A'][s[i]-'A']++
	}

	for i := 0; i < q; i++ {
		td := nextLine()
		t, d := td[0]-'A', td[2]
		count[t] = 0
		if d == 'R' {
			for j := 0; j < 'Z'-'A'+1; j++ {
				count[j] += gr[t][j]
			}
			count['Z'-'A'+2] += gr[t]['Z'-'A'+2]
		} else {
			for j := 0; j < 'Z'-'A'+1; j++ {
				count[j] += gl[j][t]
			}
			count['Z'-'A'+1] += gl['Z'-'A'+1][t]
		}
	}
	fmt.Println(n - count['Z'-'A'+1] - count['Z'-'A'+2])

}

func lcm(a, b int64) int64 {
	return (a / gcd(a, b)) * b
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}

func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}

func max(i, j int) int {
	if i < j {
		return j
	}
	return i
}
