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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        int[] nums = ReadInts();
        int N = nums[0];
        int Q = nums[1];
        string s = Read();
        char[,] td = new char[Q, 2];
        int los = 0;
        int cnt = 0;
        int ans = 0;
        for (int i = 0; i < Q; i++)
        {
            string[] input = Read().Split();
            char t = input[0][0];
            char d = input[1][0];
            td[i, 0] = t;
            td[i, 1] = d;
        }
        char mozi = s[0];
        for (int i = Q - 1; i >= 0; i--)
        {
            if (mozi == td[i, 0] && td[i, 1] == 'L')
            {
                if (cnt < N)
                {
                    cnt++;
                    if (cnt == N) return "0";
                    mozi = s[cnt];
                }
            }
        }
        los += cnt;
        cnt = 0;
        mozi = s[N - 1];
        for (int i = Q - 1; i >= 0; i--)
        {
            if (mozi == td[i, 0] && td[i, 1] == 'R')
            {
                if (cnt < N)
                {
                    cnt++;
                    if (cnt == N) return "0";
                    mozi = s[N - 1 - cnt];
                }
            }
        }
        los += cnt;
        los = Math.Min(los, N);
        ans = N - los;
        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}
