using System;
using System.Linq;

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

            var s = Console.ReadLine();

            var t = new char[Q];
            var d = new char[Q];
            for (int i = 0; i < Q; i++)
            {
                str = Console.ReadLine();
                t[i] = str[0];
                d[i] = str[2];
            }

            var golem = N;
            for (int i = 0; i < N; i++)
            {
                var pos = i;
                var posChar = s[i];
                var endGolem = false;
                for (int j = 0; j < Q; j++)
                {
                    if (posChar == t[j])
                    {
                        if (d[j] == 'R')
                        {
                            pos++;
                        }
                        else
                        {
                            pos--;
                        }

                        if (pos < 0 || N <= pos)
                        {
                            golem--;
                            endGolem = true;
                        }
                        else
                        {
                            posChar = s[pos];
                        }
                    }

                    if (endGolem)
                    {
                        break;
                    }
                }
            }

            Console.WriteLine(golem);
        }
    }
}
