package main

import "fmt"

func main() {
	var N, Q int
	fmt.Scanf("%d %d", &N, &Q)
	var inS string
	fmt.Scanf("%s", &inS)
	s := make([]string, N)
	golems := make([]int, N)
	index := make(map[string][]int)
	for i, r := range inS {
		s[i] = string(r)
		if _, ok := index[s[i]]; ok {
			index[s[i]] = append(index[s[i]], i)
		} else {
			index[s[i]] = []int{i}
		}
		golems[i] = 1
	}
	t := make([]string, Q)
	d := make([]string, Q)
	for i := 0; i < Q; i++ {
		fmt.Scanf("%s %s", &t[i], &d[i])
	}
	for i := 0; i < Q; i++ {
		prev := make([]int, N)
		copy(prev, golems)
		for j := 0; j < len(index[t[i]]); j++ {
			idx := index[t[i]][j]
			if d[i] == "L" && idx == 0 {
				if golems[idx] > prev[idx] {
					golems[idx] = golems[idx] - prev[idx]
				} else {
					golems[idx] = 0
				}
				continue
			}
			if d[i] == "R" && idx == N-1 {
				if golems[idx] > prev[idx] {
					golems[idx] = golems[idx] - prev[idx]
				} else {
					golems[idx] = 0
				}
				continue
			}
			if d[i] == "L" {
				golems[idx-1] = golems[idx-1] + prev[idx]
			}
			if d[i] == "R" {
				golems[idx+1] = golems[idx+1] + prev[idx]
			}
			if golems[idx] > prev[idx] {
				golems[idx] = golems[idx] - prev[idx]
			} else {
				golems[idx] = 0
			}
		}
	}
	count := 0
	for i := 0; i < N; i++ {
		count += golems[i]
	}
	fmt.Println(count)
}
