using System;

    class Program
    {
        static void Main(string[] args)
        {
            // get a int N
            string[] nq = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(nq[0]);
            int q = Convert.ToInt32(nq[1]);
            string s = Console.ReadLine();
            int[] square = new int[n];
            for (int i = 0; i < n; i++)
            {
                square[i] = 1;
            }

            Dictionary<char, List<int>> golems = new Dictionary<char, List<int>>();
            for (int i = 0; i < n; i++)
            {
                List<int> dicCheck;

                if (!golems.TryGetValue(s[i], out dicCheck))
                {
                    golems[s[i]] = new List<int>();
                }
                golems[s[i]].Add(i);
            }

            for (int i = 0; i < q; i++)
            {
                string[] td = Console.ReadLine().Split(' ');
                string t = td[0];
                string d = td[1];

                List<int> movable;
                if (golems.TryGetValue(t[0], out movable))
                {
                    int[] expectedSquare = (int[])square.Clone();
                    foreach (int pos in movable)
                    {
                        if (d[0] == 'L')
                        {
                            if (pos != 0)
                            {
                                expectedSquare[pos - 1] += square[pos];
                            }
                            expectedSquare[pos] -= square[pos];
                        }
                        else
                        {
                            if (pos != n - 1)
                            {
                                expectedSquare[pos + 1] += square[pos];
                            }
                            expectedSquare[pos] -= square[pos];
                        }
                    }

                    square = expectedSquare;
                }
            }

            int count = 0;
            for (int i = 0; i < n; i++)
            {
                count += square[i];
            }

            Console.WriteLine(count);
        }
    }