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

namespace Q2
{
    class Program
    {
        static void Main(string[] args)
        {
            kotae k = new kotae();
            Console.WriteLine(k.GetResult());
        }

        public class kotae
        {
            string s, t, d;
            public int GetResult()
            {
                string line = Console.ReadLine();
                string[] strs = line.Split(' ');
                int N = int.Parse(strs[0]);
                int Q = int.Parse(strs[1]);
                s = Console.ReadLine();
                t = "";
                d = "";
                for (int i = 0; i < Q; i++)
                {
                    line = Console.ReadLine();
                    strs = line.Split(' ');
                    t += strs[0];
                    d += strs[1];
                }

                //フェーズ1：真ん中から左へオーバーする限界を調べていく
                int l_will_delete_position = -1;
                int r_will_delete_position = -1;
                int l_limit = 0;
                int r_limit = N - 1;
                int r_r_limit = N - 1;
                while (l_limit <= r_limit)
                {
                    int middle = (l_limit + r_limit) / 2;
                    int result = WillBeDeletedLeft(middle);
                    if (result == 0)
                    {
                        l_limit = middle + 1;
                        l_will_delete_position = middle;
                    }
                    else
                    {
                        r_limit = middle - 1;
                        if (result==1)
                        {
                            r_r_limit = middle;
                            r_will_delete_position = middle;
                        }
                    }
                }
                if (l_limit == 0)
                {
                    if (WillBeDeletedLeft(0) == 0)
                    {
                        l_will_delete_position = 0;
                    }
                    else
                    {
                        l_will_delete_position = -1;
                    }
                }

                //フェーズ2:真ん中から右へオーバーする限界を調べていく
                l_limit = l_will_delete_position == -1 ? 0 : l_will_delete_position + 1;
                while (l_limit <= r_r_limit)
                {
                    int middle = (l_limit + r_r_limit + 1) / 2;
                    if (WillBeDeletedRight(middle))
                    {
                        r_r_limit = middle - 1;
                        r_will_delete_position = middle;
                    }
                    else
                    {
                        l_limit = middle + 1;
                    }
                }
                if (r_r_limit == N - 1)
                {
                    if (WillBeDeletedRight(N - 1))
                    {
                        r_will_delete_position = N - 1;
                    }
                    else
                    {
                        r_will_delete_position = N;
                    }
                }
                return r_will_delete_position - l_will_delete_position - 1;
            }
            public int WillBeDeletedLeft(int initial_position)
            {
                int position = initial_position;
                for (int i = 0; i < t.Length; i++)
                {
                    if (s[position] == t[i])
                    {
                        if (d[i] == 'L')
                        {
                            //左へ
                            position--;
                        }
                        else position++;

                        if (position < 0) return 0;
                        if (position >= s.Length) return 1;//右にいってしまった
                    }
                }
                return -1;
            }

            public bool WillBeDeletedRight(int initial_position)
            {
                int position = initial_position;
                for (int i = 0; i < t.Length; i++)
                {
                    if (s[position] == t[i])
                    {
                        if (d[i] == 'L')
                        {
                            //左へ
                            position--;
                        }
                        else position++;

                        if (position < 0)
                            return false;//左にいってしまった
                        if (position >= s.Length)
                            return true;
                    }
                }
                return false;
            }
        }

        
    }
}
