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 string s = "";
        public static string[] magic;
        static void Main(string[] args)
        {
            // 整数の入力
            //int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            string[] inputNQ = Console.ReadLine().Split(' ');
            int N = int.Parse(inputNQ[0]);//文字数
            int Q = int.Parse(inputNQ[1]);//呪文の数
            // 文字列の入力
            s = Console.ReadLine();
            //　呪文の入力
            magic = new string[Q];
            for (int i = 0; i < Q; i++)
            {
                magic[i] = Console.ReadLine();
            }
            string s1 = s.Substring(0, 1);//文字列の左端から1文字ずつ、そのすぐ右隣をチェックする
            string s2 = s.Substring(s.Length - 1, 1);
            //Console.WriteLine("N="+N);
            int ansL=search_L(magic.Length, s1);
            int ansR=search_R(magic.Length, s2);
            Console.WriteLine(N- ansL- ansR);
        }
        // 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;
            }
        }
    }
}
