using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int Q = int.Parse(s[1]);

            char[] c = Console.ReadLine().ToCharArray();

            int[] pos = new int[N+2];

            for (int i = 1; i <= N; i++)
                pos[i] = 1;

            for (int z = 0; z < Q; z++)
            {
                char[] qc = Console.ReadLine().ToCharArray();

                for(int i=1;i<=N;i++)
                {
                    if(c[i-1] == qc[0])
                    {
                        if(qc[2] == 'L')
                        {
                            pos[i - 1] += pos[i];
                            pos[i] = 0;
                        }
                        else
                        {
                            pos[i + 1] += pos[i];
                            pos[i] = 0;
                        }
                    }

                }
            }

            int ans = 0;

            for(int i=1;i<=N;i++)
            {
                ans += pos[i];
            }


            Console.WriteLine(ans.ToString());
        }
    }
}
