package main

import "fmt"

func main() {

	var (
		n  int
		q  int
		ss string
		s  []string
		t  string
		d  string
	)

	fmt.Scan(&n, &q)
	fmt.Scan(&ss)

	for _, c := range ss {
		s = append(s, string([]rune{c}))
	}
	fmt.Println("s:", s)

	td := make([][]string, q)
	for i := 0; i < q; i++ {
		fmt.Scan(&t, &d)
		td[i] = []string{t, d}
	}
	fmt.Println("td:", td)

	leftIndex := solveLeft(-1, n, n, q, s, td)
	rightIndex := solveRight(-1, n, n, q, s, td)

	fmt.Print(rightIndex - leftIndex - 1)

}

func solveLeft(l int, r int, n int, q int, s []string, td [][]string) int {
	mid := int((r + l) / 2)
	if r-l <= 1 {
		return l
	}
	index := mid
	for i := 0; i < q; i++ {
		if td[i][0] == s[index] {
			if td[i][1] == "L" {
				index--
				if index == -1 {
					return solveLeft(mid, r, n, q, s, td)
				}
			} else {
				index++
				if index == n {
					return solveLeft(l, mid, n, q, s, td)
				}
			}
		}
	}
	return solveLeft(l, mid, n, q, s, td)
}

func solveRight(l int, r int, n int, q int, s []string, td [][]string) int {
	mid := int((r + l) / 2)
	if r-l <= 1 {
		return r
	}
	index := mid
	for i := 0; i < q; i++ {
		if td[i][0] == s[index] {
			if td[i][1] == "R" {
				index++
				if index == n {
					return solveRight(l, mid, n, q, s, td)
				}
			} else {
				index--
				if index == -1 {
					return solveRight(mid, r, n, q, s, td)
				}
			}
		}
	}
	return solveRight(mid, r, n, q, s, td)
}
