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

class Myon{
    static void Main(string[] args){
        string[] input1 = Console.ReadLine().Split(' ');
        int N = int.Parse(input1[0]);
        int Q = int.Parse(input1[1]);

        int count = 0;

        string s = Console.ReadLine();

        int[] num = new int[N];
        /*for(int i = 0;i < N;i ++){
        	num[i] = 1;
        }*/


        List<int>[] address = new List<int>[26];
      	for(int i = 0;i < 26;i ++){
        	address[i] = new List<int>();
        }
        for(int i = 0;i < N;i++){
            address[Index(s[i])].Add(i);
            num[i] = 1;
        }

        for(int i = 0;i < Q;i ++){
            string[] input = Console.ReadLine().Split(' ');
            char t = input[0][0];
            char d = input[1][0];


            //ｓに一致するやつがいるかサーチ
            for(int k = 0;k < address[Index(t)].Count;k ++){
                int j = address[Index(t)][k];
                if(s[j] == t){
                    
                    if((j == 0 && d == 'L') || (j == N - 1 && d == 'R')){
                      count += num[j];
                      num[j] = 0;
            			
                    }else{


                        if(d == 'R'){
                            num[j + 1] += num[j];
                            num[j] = 0;
                        }else
                        {
                            num[j - 1 ] += num[j];
                            num[j] = 0;
                        }
                    }

                }

            }
        }

        //int count = 0;
        /*for(int i = 0;i < N;i ++){
        	count += num[i];
        }*/

        Console.WriteLine( N - count);
    }

    static int Index(char c){

        if(c =='A')return 0;
        else if(c =='B')return 1;
        else if(c =='C')return 2;
        else if(c =='D')return 3;
        else if(c =='E')return 4;
        else if(c =='F')return 5;
        else if(c =='G')return 6;
        else if(c =='H')return 7;
        else if(c =='I')return 8;
        else if(c =='J')return 9;
        else if(c =='K')return 10;
        else if(c =='L')return 11;
        else if(c =='M')return 12;
        else if(c =='N')return 13;
        else if(c =='O')return 14;
        else if(c =='P')return 15;
        else if(c =='Q')return 16;
        else if(c =='R')return 17;
        else if(c =='S')return 18;
        else if(c =='T')return 19;
      	else if(c =='U')return 20;
        else if(c =='V')return 21;
        else if(c =='W')return 22;
        else if(c =='X')return 23;
        else if(c =='Y')return 24;
        else if(c =='Z')return 25;
		else return 0;
    }
}