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

class Program
{
    static void Main(string[] args)
    {

        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int Q = int.Parse(input[1]);
        string s = Console.ReadLine();
        int[] monster = new int[N];
        for(int i = 0; i < N; i++)
        {
            monster[i] = 1;
        }
        for(int i = 0; i < Q; i++)
        {
            string[] temp= Console.ReadLine().Split(' ');
            char t = char.Parse(temp[0]);
            char d = char.Parse(temp[1]);
            for (int j = 0; j < s.Length; j++)
            {
                if (s[j] == t) {
                    if (d == 'L')
                    {
                        if (j != 0) { monster[j - 1] += monster[j];}
                        monster[j] = 0;
                    }
                    else
                    {
                        if (j != s.Length-1) { monster[j+1] += monster[j]; }
                        monster[j] = 0;
                    }
                }
            }
        }
        int ans = 0;
        for(int i = 0; i < N; i++)
        {
            ans += monster[i];
        }
        Console.WriteLine(ans);

    }
}

