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

namespace Exawizards_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int Q = int.Parse(input[1]);

            string s = Console.ReadLine();

            Dictionary<char, List<int>> nameIndex = new Dictionary<char, List<int>>();

            string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            for (int i = 0; i < alphabet.Length; i++)
            {
                List<int> list = new List<int>();
                nameIndex.Add(alphabet[i], list);
            }

            int[] golemCount = new int[N];
            for (int i=0; i<N; i++)
            {
                char c = s[i];
                nameIndex[c].Add(i);

                golemCount[i] = 1;
            }


            int deleteCount = 0;
            for (int i=0; i<Q; i++)
            {
                string[] cmd = Console.ReadLine().Split(' ');
                char t = cmd[0][0];
                char d = cmd[1][0];
                /*
                List<int> list = nameIndex[t];
                for(int j=0; j<list.Count; j++)
                {
                    int pos = list[j];
                    if (d=='L')
                    {
                        if(pos==0)
                        {
                            deleteCount += golemCount[0];
                            golemCount[0] = 0;
                        }
                        else
                        {
                            golemCount[pos - 1] += golemCount[pos];
                            golemCount[pos] = 0;
                        }
                    }
                    else
                    {
                        if (pos == N-1)
                        {
                            deleteCount += golemCount[N-1];
                            golemCount[N - 1] = 0;
                        }
                        else
                        {
                            golemCount[pos + 1] += golemCount[pos];
                            golemCount[pos] = 0;
                        }
                    }
                }
                */
            }
            Console.WriteLine(N - deleteCount);
        }
    }
}
