using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
    static string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    static int n;
    static int q;
    static int[] s;
    static int[] t;
    static char[] d;

    static void Main(){
        string[] input = Console.ReadLine().Split();
        n = int.Parse(input[0]);
        q = int.Parse(input[1]);
        s = Console.ReadLine().ToCharArray().Select(p => InvAlp(p)).ToArray();
        t = new int[q];
        d = new char[q];
        for (int i = 0; i < q; i++)
        {
            input = Console.ReadLine().Split();
            t[i] = InvAlp(input[0][0]);
            d[i] = input[1][0];
        }

        HashSet<int> hs = new HashSet<int>();
        for (int i = q - 1; i >= 0;i--){
            int qt = t[i];
            char qd = d[i];
            HashSet<int> hs2 = new HashSet<int>();
            foreach (var j in hs)
            {
                if (j > 1 && s[j - 2] == qt && qd == 'R') hs2.Add(j - 1);
                if (j < n && s[j] == qt && qd == 'L') hs2.Add(j + 1);
                if (s[j - 1] != qt) hs2.Add(j);
            }
            if (qt == s[0] && qd == 'L') hs2.Add(1);
            if (qt == s[n - 1] && qd == 'R') hs2.Add(n);
            hs = hs2;
        }

        Console.WriteLine(n - hs.Count);
    }

    static int InvAlp(char c){
        for (int i = 0; i < alp.Length; i++)
            if (alp[i] == c) return i;
        return -1;
    }
}