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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NQ = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = NQ[0];
            var Q = NQ[1];
            var s = Console.ReadLine();
            var tdList = Enumerable.Range(0, Q).Select(_ => Console.ReadLine().Split(' '));

            var golemCountList = new int[s.Length + 2];
            var memo = new Dictionary<char, List<int>>();

            for (var i = 0; i < s.Length; i++)
            {
                List<int> list;
                if (!memo.TryGetValue(s[i], out list))
                {
                    list = new List<int>();
                    memo.Add(s[i], list);
                }

                list.Add(i + 1);
                golemCountList[i + 1] = 1;
            }

            foreach (var td in tdList)
            {
                var t = td[0][0];
                var d = td[1][0];

                if (!memo.ContainsKey(t)) continue;

                foreach (var i in memo[t])
                {
                    var next = d == 'L' ? i - 1 : i + 1;
                    golemCountList[next] += golemCountList[i];
                    golemCountList[i] = 0;
                }
            }

            var output = s.Length - golemCountList[0] - golemCountList.Last();
            Console.WriteLine(output);
        }
    }
}
