package main

import "fmt"

type point struct {
	num int
	str string
}

func main() {

	var (
		n int
		q int
		s string
		t string
		d string
	)
	var (
		p   []point
		cnt int
	)

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

	input := point{}
	for _, c := range s {
		input.num = 1
		input.str = string([]rune{c})
		p = append(p, input)
	}

	for i := 0; i < q; i++ {
		fmt.Scan(&t, &d)
		for j := 0; j < n; j++ {
			if p[j].str == t {
				if d == "R" {
					if j+1 >= n {
						p[j].num = 0
					} else {
						p[j+1].num = p[j+1].num + p[j].num
						p[j].num = 0
					}
				} else if d == "L" {
					if j-1 < 0 {
						p[j].num = 0
					} else {
						p[j-1].num = p[j-1].num + p[j].num
						p[j].num = 0
					}
				}
			}
		}
	}

	for i := 0; i < n; i++ {
		cnt = cnt + p[i].num
	}

	fmt.Print(cnt)

}
