package main

import (
	"fmt"
)

var (
	n           int
	q           int
	s           string
	t           []byte
	d           []byte
	g           []int
	charToIndex map[byte][]int
)

func solve() {
	for i := 0; i < q; i++ {
		char := t[i]
		indices := charToIndex[char]
		if indices == nil {
			continue
		}
		for _, j := range indices {
			if s[j] == t[i] && g[j] > 0 {
				if d[i] == 'L' {
					move := g[j]
					g[j] = 0
					if j > 0 {
						g[j-1] += move
					}
				}
				if d[i] == 'R' {
					move := g[j]
					g[j] = 0
					if j < n-1 {
						g[j+1] += move
					}
				}
			}
		}
	}

	sum := 0
	for i := 0; i < n; i++ {
		sum += g[i]
	}
	fmt.Println(sum)
}

func main() {
	fmt.Scan(&n)
	fmt.Scan(&q)
	fmt.Scan(&s)

	g = make([]int, n)
	for i := 0; i < n; i++ {
		g[i] = 1
	}

	t = make([]byte, q)
	d = make([]byte, q)

	charToIndex = map[byte][]int{}

	for i := 0; i < q; i++ {
		tmp := ""
		fmt.Scan(&tmp)
		t[i] = tmp[0]
		fmt.Scan(&tmp)
		d[i] = tmp[0]
	}

	for i := 0; i < len(s); i++ {
		if charToIndex[s[i]] == nil {
			charToIndex[s[i]] = []int{}
		}
		charToIndex[s[i]] = append(charToIndex[s[i]], i)
	}

	solve()
}
