using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		(new Solver()).Solve();
	}	
}


public class Solver
{
	private int N;
	private int Q;
	private string s;
	private char[] t;
	private char[] d;

	public Solver()
	{
		N = GetInt();
		Q = GetInt();
		s = "\0" + GetString();
		t = new char[Q];
		d = new char[Q];
		for(int i = 0; i < Q; i++)
		{
			t[i] = GetString()[0];
			d[i] = GetString()[0];
		}
	}

	public void Solve()
	{
		int lbl = 0;
		int ubl = N + 1;
		while(lbl + 1 < ubl)
		{
			int mid = (lbl + ubl)/2;
			if(move(mid) == 0)
				lbl = mid;
			else
				ubl = mid - 1;
		}

		int lbr = 0;
		int ubr = N + 1;
		while(lbr + 1 < ubr)
		{
			int mid = (lbr + ubr)/2;
			if(move(mid) == N + 1)
				ubr = mid;
			else
				lbr = mid + 1;
		}

		Console.WriteLine(ubr - ubl - 1);
	}


	private int move(int x)
	{
		if((x == 0) || (x == N + 1))
			return x;

		int currentX = x;
		for(int i = 0; i < Q; i++)
		{
			if(s[currentX] != t[i])
				continue;

			if(d[i] == 'L')
			{
				if(currentX == 1)
					return 0;
				else	
					currentX--;
			}
			else
			{
				if(currentX == N)
					return N + 1;
				else
					currentX++;
			}
		}

		return currentX;
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}
