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

    class Program
    {
        static void Main(string[] args)
        {
            // get a int N
            string[] nq = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(nq[0]);
            int q = Convert.ToInt32(nq[1]);
            string s = Console.ReadLine();
            Square[] square = new Square[n];
            for (int i = 0; i < n; i++)
            {
                square[i] = new Square(i, square);
            }

            Dictionary<char, List<Square>> golems = new Dictionary<char, List<Square>>();
            for (int i = 0; i < n; i++)
            {
                List<Square> dicCheck;

                if (!golems.TryGetValue(s[i], out dicCheck))
                {
                    golems[s[i]] = new List<Square>();
                }
                golems[s[i]].Add(square[i]);
            }

            for (int i = 0; i < q; i++)
            {
                string[] td = Console.ReadLine().Split(' ');
                string t = td[0];
                string d = td[1];

                List<Square> movable;
                if (golems.TryGetValue(t[0], out movable))
                {
                    foreach (Square sq in movable)
                    {
                        if (d[0] == 'L')
                        {
                            sq.MoveLeft();
                        }
                        else
                        {
                            sq.MoveRight();
                        }
                    }


                    for (int k = 0; k < n; k++)
                    {
                        square[k].ClearStack();
                    }
                }

            }

            int count = 0;
            for (int i = 0; i < n; i++)
            {
                count += square[i].Stack;
            }

            Console.WriteLine(count);
        }
      
    class Square
    {
        char name;
        Square left = null;
        Square right = null;
        int stack = 1;
        int removeStack = 0;
        int addStack = 0;

        public int Stack { get => stack; set => stack = value; }

        public Square(int pos, Square[] squares)
        {
            if (pos != 0)
            {
                left = squares[pos - 1];
                left.Connect(this);
            }
        }
        public void Connect(Square right)
        {
            this.right = right;
        }
        public void ClearStack()
        {
            Stack += addStack;
            Stack -= removeStack;
            removeStack = 0;
            addStack = 0;
        }
        public void MovedFrom(int golems)
        {
            addStack += golems;
        }
        public void MoveLeft()
        {
            if (left != null)
                left.MovedFrom(Stack);
            removeStack = Stack;
        }
        public void MoveRight()
        {
            if (right != null)
                right.MovedFrom(Stack);
            removeStack = Stack;
        }
    }
    }
