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)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int N = int.Parse(strs[0]);
            int Q = int.Parse(strs[1]);

            string s = Console.ReadLine();
            string t = "";
            string 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 l_limit = 0;
            int r_limit = N - 1;
            while(l_limit <= r_limit)
            {
                int middle = (l_limit + r_limit) / 2;
                if (WillBeDeletedLeft(s,t,d, middle))
                {
                    l_limit = middle+1;
                    l_will_delete_position = middle;
                }
                else
                {
                    r_limit = middle-1;
                }
            }
            if (l_limit == 0)
            {
                if (WillBeDeletedLeft(s, t, d, 0))
                {
                    l_will_delete_position = 0;
                }
                else
                {
                    l_will_delete_position = -1;
                }
            }

            //フェーズ2:真ん中から右へオーバーする限界を調べていく
            int r_will_delete_position = -1;
            l_limit = l_will_delete_position == -1 ? 0 : l_will_delete_position + 1;
            r_limit = N - 1;
            while (l_limit <= r_limit)
            {
                int middle = (l_limit + r_limit + 1) / 2;
                if (WillBeDeletedRight(s, t, d, middle))
                {
                    r_limit = middle - 1;
                    r_will_delete_position = middle;
                }
                else
                {
                    l_limit = middle + 1;
                }
            }
            if (r_limit == N - 1 )
            {
                if (WillBeDeletedRight(s, t, d, N - 1))
                {
                    r_will_delete_position = N - 1;
                }
                else
                {
                    r_will_delete_position = N;
                }
            }

            int result = 0;
            result += r_will_delete_position - l_will_delete_position - 1;
            Console.WriteLine(result);
        }

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

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

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

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