package main

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

var sc = bufio.NewScanner(os.Stdin)

func shiftLeftToIndex(list []string, index int) {
	if index == 0 {
		list[0] = ""
	} else {
		tmp := list[index]
		list[index] = ""
		list[index-1] += tmp
	}
}

func shiftLeft(list []string, indexList []int) {
	for _, i := range indexList {
		shiftLeftToIndex(list, i)
	}
}

func shiftRightToIndex(list []string, index int) {
	if index == len(list)-1 {
		list[len(list)-1] = ""
	} else {
		tmp := list[index]
		list[index] = ""
		list[index+1] += tmp
	}
}

func shiftRight(list []string, indexList []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(indexList)))
	for _, i := range indexList {
		shiftRightToIndex(list, i)
	}
}

func countGolem(list []string) int {
	count := 0
	for _, v := range list {
		count += len(v)
	}
	return count
}

func main() {
	var n, q int
	fmt.Scan(&n, &q)
	var s string
	fmt.Scan(&s)
	sList := strings.Split(s, "")
	// 呪文の数ループ
	for i := 0; i < q; i++ {
		var t, d string
		fmt.Scan(&t, &d)
		// 移動対象のインデックスたち
		shiftIndexes := make([]int, 0, len(sList))
		// マスの分ループ
		for j := 0; j < len(sList); j++ {
			// 動かす対象か
			if strings.Contains(sList[j], t) {
				shiftIndexes = append(shiftIndexes, j)
			}
		}
		// fmt.Println("sList = ", sList, " shiftIndexes = ", shiftIndexes)
		if d == "L" {
			// 左
			shiftLeft(sList, shiftIndexes)
		} else {
			// 右
			shiftRight(sList, shiftIndexes)
		}
	}
	// fmt.Println("sList = ", sList)
	fmt.Println(countGolem(sList))
}
