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

class Program
{
    static void Main(string[] args)
    {
        string[] input1 = Console.ReadLine().Split(' ');
        int n = int.Parse(input1[0]);
        int q = int.Parse(input1[1]);
        string s = Console.ReadLine();
        List<int> golems = Enumerable.Repeat<int>(1, n).ToList();

        for (int count = 1; count <= q; count++)
        {
            string[] input2 = Console.ReadLine().Split(' ');
            char t = char.Parse(input2[0]);
            string d = input2[1];

            if (d == "R")
            {
                golems.Reverse();
                s.Reverse();
            }

            for (int i = 0; i < n; i++)
            {
                if (s[i] == t)
                {
                    if (i == 0)
                    {
                        golems[i] = 0;
                    }
                    else if (golems[i] > 0)
                    {
                        golems[i-1] = golems[i-1] + golems[i];
                        golems[i] = 0;
                    }
                }
            }

            if (d == "R")
            {
                golems.Reverse();
                s.Reverse();
            }
        }
        Console.WriteLine(golems.Sum());
    }
}
