package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	q := readInt()
	sx := []byte(readString())
	t := make([]int, q)
	d := make([]string, q)

	s := make([]int, n+2)
	s[0] = -1
	for i := 1; i <= n; i++ {
		s[i] = int(sx[i-1] - 'A')
	}
	s[n+1] = -1

	for i := 0; i < q; i++ {
		t[i] = int([]byte(readString())[0] - 'A')
		d[i] = readString()
	}

	l := 0
	r := n + 1
	maxl, minr := l, r
	for i := q - 1; i >= 0; i-- {
		ti := t[i]
		di := d[i]
		//eprintln(string([]byte{byte(ti) + 'A'}), di, l, r)

		if di == "L" {
			if ti == s[l+1] {
				l++
			}
			if ti == s[r] {
				r++
			}
		} else {
			if ti == s[r-1] {
				r--
			}
			if ti == s[l] {
				l--
			}
		}

		if l+1 == r {
			println(0)
			return
		}

		if maxl < l {
			maxl = l
		}

		if r < minr {
			minr = r
		}
	}

	println(minr - maxl - 1)
}

// -----------------------------------------------------------------------------
