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 = Enumerable.Repeat(1, s.Length + 2).ToArray();
            golemCountList[0] = 0;
            golemCountList[golemCountList.Length - 1] = 0;

            var memo = new Dictionary<char, List<int>>();

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

                memo[s[i]].Add(i + 1);
            }

            foreach (var td in tdList)
            {
                var t = td[0][0];
                var d = td[1][0];
                var dd = d == 'L' ? -1 : 1;

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

                foreach (var i in memo[t])
                {
                    var next = i + dd;
                    golemCountList[next] += golemCountList[i];
                    golemCountList[i] = 0;
                }
            }

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