
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    public class MainClass
    {

        public static void Main(string[] args)
        {
            if (args.Length > 0 && args[0] == "debug")
            {
                var text = @"
10 15
SNCZWRCEWB
B R
R R
E R
W R
Z L
S R
Q L
W L
B R
C L
A L
N L
E R
Z L
S L
				";
                var reader = new System.IO.StringReader(text.Trim());
                Console.SetIn(reader);
            }

            checked
            {
                var paramsList = Console.ReadLine().Split(' ').ToList();
                // NQ
                var N = int.Parse(paramsList[0]);
                var Q = int.Parse(paramsList[1]);

                // TODO 両端にゴミ箱
                var s = Console.ReadLine();

                var magic = EnumerablePlus
                    .Repeat(Q, Console.ReadLine)
                    .Select(line => line.Split(' '))
                    .Select(list => new { target = list[0][0], d = list[1][0] })
                    .ToList();

                var boxes = Enumerable.Repeat(1, N).ToList();

                foreach (var item in magic)
                {

                    if (item.d == 'L')
                    {
                        for (int idx = 0; idx < N; ++idx)
                        {
                            char c = s[idx];
                            if (item.target != c) continue;

                            if (idx > 0)
                            {
                                boxes[idx - 1] += boxes[idx];
                            }
                            boxes[idx] = 0;
                        }
                    }
                    else
                    {
                        for (int idx = N - 1; idx >= 0; --idx)
                        {
                            char c = s[idx];
                            if (item.target != c) continue;

                            if (idx < N - 1)
                            {
                                boxes[idx + 1] += boxes[idx];
                            }
                            boxes[idx] = 0;
                        }
                    }
                }

                Console.WriteLine(boxes.Sum());
            }
        }

    }

    public static class EnumerablePlus
    {
        ///<summary>出力文字列に変換。</summary>
        public static string MkString<T>(this IEnumerable<T> list)
        {
            return list.Aggregate(
                new System.Text.StringBuilder(),
                (a, b) => ((a.Length > 0) ? a.Append(' ') : a).Append(b)
                ).ToString();
        }

        ///<summary>添字付きfor。</summary>
        public static void ForEach<T>(this IEnumerable<T> list, Action<T, int> a)
        {
            int i = 0;
            foreach (var item in list)
            {
                a(item, i);
            }
        }

        ///<summary>指定回数デリゲートを呼び出す。</summary>
        public static IEnumerable<T> Repeat<T>(int n, Func<T> f)
        {
            for (int i = 0; i < n; i++)
            {
                yield return f();
            }
        }
    }

}
