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

namespace SnukeTheWizard
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            string s;
            Spell[] spells;
            GetInput(out s, out spells);
            Console.WriteLine(Solve(s, spells));

        }

        private static int Solve(string s, Spell[] spells)
        {
        
            int[] counts = new int[s.Length];
            for (int i = 0; i < counts.Length; i++)
            {
                counts[i] = 1;
            }


            foreach (Spell spell in spells)
            {
                if (spell.D == 'L')
                {
                    for (int i = 0; i < counts.Length; i++)
                    {
                        if (s[i] == spell.T)
                        {
                            if (i > 0)
                            {
                                counts[i - 1] += counts[i];
                            }
                            counts[i] = 0;
                        }
                    }
                }
                else
                {
                    for (int i = counts.Length-1; i >=0; i--)
                    {
                        if (s[i] == spell.T)
                        {
                            if (i < counts.Length - 1)
                            {
                                counts[i + 1] += counts[i];
                            }
                            counts[i] = 0;
                        }
                    }
                }
            }
            return counts.Sum();
        }

        private static void GetInput(out string s, out Spell[] spells)
        {
            int[] nums = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToArray();

            int n = nums[0];
            int q = nums[1];
            s = Console.ReadLine();
            spells = new Spell[q];
            for (int i = 0; i < q; i++)
            {
                spells[i] = Spell.Parse(Console.ReadLine());
            }
        }

        private class Spell
        {
            public static Spell Parse(string line)
            {
                return new Spell(line[0], line[2]);

            }
            public char T { get; protected set; }
            public char D { get; protected set; }
            public Spell(char t, char d) { T = t; D = d; }
        }


    }
}
