package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, q int
	var s string
	fmt.Scan(&n, &q, &s)

	m := make(map[string]int, n)
	for i := 0; i < n; i++ {
		str := s[i : i+1]
		m[str] = 1
	}
	fmt.Println(m)

	for i := 0; i < q; i++ {
		var t, d string
		fmt.Scan(&t, &d)

		num := strings.Index(s, t)
		if num == 0 && d == "L" {
			value := m[t]
			m[t] -= value
		} else if num == len(s)-1 && d == "R" {
			value := m[t]
			m[t] -= value
		} else if d == "R" {
			value := m[t]
			m[t] -= value
			m[s[num+1:num+2]] += value
		} else if d == "L" {
			value := m[t]
			m[t] -= value
			m[s[num-1:num]] += value
		}
	}
fmt.Println(m)
	var sum int
	for _, v := range m {
		sum += v
	}

	fmt.Println(sum)
}
