using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int Q = int.Parse(str[1]);
		string s = Console.ReadLine();
		string[]T = new string[Q];
		string[]D = new string[Q];
		for(var i=0;i<Q;i++){
			string[] str2 = Console.ReadLine().Split();
			T[i] = str2[0];
			D[i] = str2[1];
		}
		string aaa = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		var LI = new HashSet<int[]>();
		for(var i=0;i<N;i++){
			LI.Add(new int[2]{i,1});
		}
		for(var i=0;i<Q;i++){
			var LI2 = new HashSet<int[]>();
			foreach(var L in LI){
				if(L[0]>=0 && L[0] < N && T[i]== s.Substring(L[0],1)){
					if(D[i]=="L"){
						L[0]--;
					}
					if(D[i]=="R"){
						L[0]++;
					}
				}
			}
		}
		int ans = 0;
		foreach(var L in LI){
			if(L[0]>=0 && L[0]<N){
				ans += L[1];
			}
		}
		Console.WriteLine(ans);
	}
}