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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = vals[0];
        var q = vals[1];
        var s = Console.ReadLine();
        var t = new char[q];
        var dir = new char[q];
        for (int i = 0; i < q; i++)
        {
            var strs = Console.ReadLine().Split(' ');
            t[i] = strs[0][0];
            dir[i] = strs[1][0];
        }

        int golem = n;
        for (int i = q - 1; i >= 0; i--)
        {
            var c = t[i];
            var d = dir[i];
            if (d == 'L' && c == s[0])
            {
                //Console.Error.WriteLine($"q:{i} Left");
                HashSet<int> pos = new HashSet<int> { 0 };
                for (int j = i - 1; j >= 0 && pos.Count > 0; j--)
                {
                    var cc = t[j];
                    var dd = dir[j];
                    var prev = new HashSet<int>();
                    foreach (var p in pos)
                    {
                        if (s[p] != cc)
                        {
                            prev.Add(p);

                        }
                        if (p > 0 && s[p - 1] == cc && dd == 'R')
                        {
                            prev.Add(p - 1);
                        }
                        if (p < n - 1 && s[p + 1] == cc && dd == 'L')
                        {
                            prev.Add(p + 1);
                        }
                    }
                    pos = prev;
                    //Console.Error.WriteLine(string.Join(" ", pos));
                }
                golem -= pos.Count;
            }
            else if (d == 'R' && c == s[n - 1])
            {
                //Console.Error.WriteLine($"q:{i} Right");
                HashSet<int> pos = new HashSet<int> { n - 1 };
                for (int j = i - 1; j >= 0 && pos.Count > 0; j--)
                {
                    var cc = t[j];
                    var dd = dir[j];
                    var prev = new HashSet<int>();
                    foreach (var p in pos)
                    {
                        if (s[p] != cc)
                        {
                            prev.Add(p);

                        }
                        if (p > 0 && s[p - 1] == cc && dd == 'R')
                        {
                            prev.Add(p - 1);
                        }
                        if (p < n - 1 && s[p + 1] == cc && dd == 'L')
                        {
                            prev.Add(p + 1);
                        }
                    }
                    pos = prev;
                    //Console.Error.WriteLine(string.Join(" ", pos));
                }
                golem -= pos.Count;
            }
        }

        Console.WriteLine(golem);
    }
}