using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExaWizards2019C3
{
    class Program
    {
        public static int counter_L = 0;
        public static int counter_R = 0;
        public static int ans_MaxL = 0;
        public static int ans_MaxR = 0;
        public static string s = "";
        public static List<string> magic = new List<string>();
        static void Main(string[] args)
        {
            // スペース区切りの整数の入力
            string[] inputNQ = Console.ReadLine().Split(' ');
            int N = int.Parse(inputNQ[0]);//文字数
            int Q = int.Parse(inputNQ[1]);//呪文の数
            // 文字列の入力
            s = Console.ReadLine();
            //　呪文の入力
            for (int i = 0; i < Q; i++)
            {
                string m = Console.ReadLine();
                magic.Add(m);
                if ((magic[i].Substring(0, 1) == s.Substring(0, 1))&&(magic[i].Substring(2, 1) =="L"))
                {
                    //Console.WriteLine("this-L");
                    int ans_TmpL = 0;
                    counter_L = 0;
                    ans_TmpL= search_L(magic.Count, s.Substring(0, 1));
                    if (ans_TmpL > ans_MaxL) ans_MaxL = ans_TmpL;
                   //Console.WriteLine(ans_MaxL);
                }
                if ((magic[i].Substring(0, 1) == s.Substring(s.Length-1, 1)) && (magic[i].Substring(2, 1) == "R"))
                {
                    //Console.WriteLine("that-R");
                    int ans_TmpR = 0;
                    counter_R = 0;
                    ans_TmpR = search_R(magic.Count, s.Substring(s.Length-1, 1));
                    if (ans_TmpR > ans_MaxR) ans_MaxR = ans_TmpR;
                    //Console.WriteLine(ans_MaxR);
                }
            }
            Console.WriteLine(N-ans_MaxL-ans_MaxR);
        }
        // int i magic配列の何番から探し始めるか
        // string s1探す文字
        public static int search_L(int i,string s1)
        {
            bool check_L = true;
            if (i == 0)
            {
                return counter_L;
            }
            else
            {
                for (int j = i-1; j >=0; j--)
                    {
                        if ((magic[j].Substring(0, 1) == s1) && (magic[j].Substring(2, 1) == "L"))
                        {
                            for (int k = j-1; k > j; k--)
                            {
                                if((magic[k].Substring(0, 1) == s1) && (magic[k].Substring(2, 1) == "R"))
                                {
                                    check_L = false;
                                }
                            }
                            if (check_L == true)
                                {
                                    counter_L++;
                                    search_L(j, s.Substring(counter_L, 1));
                                    break;
                                }
                        }
                    }
                return counter_L;
             }
        }
        // int i magic配列の何番から探し始めるか
        // string s2探す文字
        public static int search_R(int i, string s2)
        {
            bool check_R = true;
            if (i == 0)
            {
                return counter_R;
            }
            else
            {
                for (int j = i - 1; j >= 0; j--)
                {
                    if ((magic[j].Substring(0, 1) == s2) && (magic[j].Substring(2, 1) == "R"))
                    {
                        for (int k = j-1; k > j; k--)
                        {
                            if((magic[j].Substring(0, 1) == s2) && (magic[j].Substring(2, 1) == "L"))
                            {
                                check_R = false;
                            }
                        }
                        if (check_R == true)
                        {
                            counter_R++;
                            search_R(j, s.Substring(s.Length-counter_R-1, 1));
                            break;
                        }
                    }
                }
                return counter_R;
            }
        }
    }
}
