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

static class CodeJam
{
    class Query
    {
        public readonly char t;
        public readonly char d;
        public Query(string[] args)
        {
            t = args[0][0];
            d = args[1][0];
        }
    }

    static int Solve(int N, int Q, string s, Query[] queries)
    {
        var list1 = new List<int>();
        for (int i = Q - 1; i >= 0; --i)
        {
            var list2 = new List<int>();
            Func<int, char> move = j => (0 <= j && j < N && s[j] == queries[i].t) ? queries[i].d : ' ';
            foreach (var j in list1)
            {
                if (move(j - 1) == 'R') { list2.Add(j - 1); }
                if (move(j) == ' ') { list2.Add(j); }
                if (move(j + 1) == 'L') { list2.Add(j + 1); }
            }
            if (queries[i].t == s[0] && queries[i].d == 'L') { list2.Add(0); }
            if (queries[i].t == s[N - 1] && queries[i].d == 'R') { list2.Add(N - 1); }
            list1 = list2;
        }
        return N - list1.Count;
    }

    static void Main(string[] args)
    {
        int[] V1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = V1[0], Q = V1[1];
        var s = Console.ReadLine();
        var queries = new Query[Q];
        for (int i = 0; i < Q; ++i)
        {
            queries[i] = new Query(Console.ReadLine().Split());
        }
        Console.WriteLine(Solve(N, Q, s, queries));
    }
}
