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


class Program
{
    public static void Main(string[] args)
    {
        var ss = Console.ReadLine().Split();
        var N = int.Parse(ss[0]);
        var Q = int.Parse(ss[1]);
        var s = Console.ReadLine().ToCharArray().Select(n => n - 'A').ToArray();

        var mark_incs = new List<Tuple<int, int>>();
        for (int i = 0; i < Q; i++)
        {
            var sss = Console.ReadLine().Split();
            var mark = sss[0][0] - 'A';
            var inc = sss[1][0] == 'L' ? -1 : 1;
            mark_incs.Add(new Tuple<int, int>(mark, inc));
        }

        var count = 0;
        for (int i = 0; i < N; i++)
        {
            var pos = i;
            foreach (var mark_inc in mark_incs)
            {
                var mark = mark_inc.Item1;
                var inc = mark_inc.Item2;

                if (s[pos] == mark)
                {
                    switch (inc)
                    {
                        case -1:
                            if (pos == 0)
                            {
                                goto L_out;
                            }
                            break;
                        case 1:
                            if (pos == (N - 1))
                            {
                                goto L_out;
                            }
                            break;
                    }
                    pos += inc;
                }
            }
            count++;
        L_out:
            ;
        }

        Console.WriteLine(count);
    }
}
