using System;
using System.Collections.Generic;
using System.Linq;

namespace EXA2019C
{
    class MainClass
    {

        static int[] nq;
        static string s;
        static List<string[]> tdlst = new List<string[]>();

        public static void Main(string[] args)
        {
            nq = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            s = Console.ReadLine();

        
           
            for (int i = 0; i < nq[1]; i++)
            {
                string[] td = Console.ReadLine().Split().ToArray();
               tdlst.Add(td);
            }

            int l = GetLeftBnd(0, nq[0] - 1);
            int r= GetRightBnd(0, nq[0] - 1);

            int ans = 0;
            if (l > r)
            {
                ans = 0;
            }
            else
            {
                ans = r - l + 1;
            }

            Console.WriteLine(ans);

        }

        public static int GetLeftBnd(int l,int r)
        {
            if (l == r)
            {
                if (IsLeftBnd(l))
                {
                    return l + 1;
                }
                else
                {
                    return l;
                }
            }
            else if (r - l == 1)
            {
                if (IsLeftBnd(r))
                {
                    return r + 1;
                }
                else if (IsLeftBnd(l))
                {
                    return r;
                }
                else
                {
                    return l;
                }
            }
            else
            {
                int mid = (l + r) / 2;
                if (IsLeftBnd(mid))
                {
                    l = mid;
                    return GetLeftBnd(l, r);
                }
                else
                {
                    r = mid;
                    return GetLeftBnd(l, r);
                }
            }
        }

        public static int GetRightBnd(int l, int r)
        {
            if (l == r)
            {
                if (IsRightBnd(r))
                {
                    return r - 1;
                }
                else
                {
                    return r;
                }
            }
            else if (r - l == 1)
            {
                if (IsRightBnd(l))
                {
                    return l-1;
                }
                else if (IsRightBnd(r))
                {
                    return l;
                }
                else
                {
                    return r;
                }
            }
            else
            {
                int mid = (l + r) / 2;
                if (IsRightBnd(mid))
                {
                    r = mid;
                    return GetRightBnd(l, r);
                }
                else
                {

                    l = mid;
                    return GetRightBnd(l, r);
                }
            }
        }

        public static bool IsLeftBnd(int idx)
        {
            bool isBnd = false;
            char nowChar = s[idx];
            int nowPos = idx;
            for (int i = 0; i < nq[1]; i++)
            {
                if (tdlst[i][0][0] == nowChar)
                {
                    if (tdlst[i][1][0] == 'L')
                    {
                        nowPos -= 1;
                        if (nowPos == -1)
                        {
                            isBnd = true;

                            break;
                        }
                        else
                        {
                            nowChar = s[nowPos];
                        }
                    }
                    else
                    {
                        nowPos += 1;
                        if (nowPos == nq[0])
                        {
                            break;
                        }
                        else
                        {
                            nowChar = s[nowPos];
                        }

                    }
                }

            }

            return isBnd;
        }

        public static bool IsRightBnd(int idx)
        {
            bool isBnd = false;
            char nowChar = s[idx];
            int nowPos = idx;
            for (int i = 0; i < nq[1]; i++)
            {
                if (tdlst[i][0][0] == nowChar)
                {
                    if (tdlst[i][1][0] == 'R')
                    {
                        nowPos += 1;
                        if (nowPos == nq[0])
                        {
                            isBnd = true;
                            break;
                        }
                        else
                        {
                            nowChar = s[nowPos];
                        }
                    }
                    else
                    {
                        nowPos -= 1;
                        if (nowPos == -1)
                        {
                            break;
                        }
                        else
                        {
                            nowChar = s[nowPos];
                        }

                    }
                }
            }
            return isBnd;
        }


    }
}


Measured memory_bytes: 44172