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

public class MainCls
{
	public static void Main(string[] args)
	{
		string[] a = Console.ReadLine().Split(' ');
		int n = int.Parse(a[0]);
		int q = int.Parse(a[1]);
		string s = Console.ReadLine();
		Dictionary<char,List<int>> d = new Dictionary<char,List<int>>();
		for(int i = 0; i < s.Length; i++)
		{
			if(!d.ContainsKey(s[i]))
				d.Add(s[i], new List<int>());
			d[s[i]].Add(i);
		}
		
		for(int i = 0; i < q; i++)
		{
			string[] c = Console.ReadLine().Split(' ');
			if(!d.ContainsKey(c[0][0]))
				continue;
				
			var k = d[c[0][0]];
			List<int> newData = new List<int>(k.Count);
			
			for(int j = 0; j < k.Count; j++)
			{
				if((uint)k[j] < s.Length)
				{
					if(c[1] == "L")
						k[j]--;
					else
						k[j]++;
					
					if((uint)k[j] < s.Length)
					{
						if(s[k[j]]==c[0][0])newData.Add(k[j]);
						else
							d[s[k[j]]].Add(k[j]);
					}
				}
				d[c[0][0]] = newData;
			}
		}
		
		int output = 0;
		foreach(var m in d.Values)
		{
			foreach(int o in m)
			{
				if(o > -1 && o < s.Length)
					output++;
			}
		}
		Console.WriteLine(output);
	}

}