using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Security.Cryptography;
using System.Text;

namespace Contest
{
    class Program
    {
        private int N, Q;
        private string S;
        private char[] t, d;
        public void Solve()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            Q = sc.NextInt();
            S = sc.Next();

            t = new char[Q];
            d = new char[Q];
            for (int i = 0; i < Q; i++)
            {
                t[i] = sc.Next()[0];
                d[i] = sc.Next()[0];
            }

            //右から落ちる
            int ok = N;
            int ng = 0;

            while (ok - ng > 1)
            {
                int med = (ok + ng) / 2;
                if (right(med))
                {
                    ok = med;
                }
                else
                {
                    ng = med;
                }

            }

            int ook = -1;
            int nng = N - 1;
            while (nng - ook > 1)
            {
                int med = (ook + nng) / 2;
                if (left(med))
                {
                    ook = med;
                }
                else
                {
                    nng = med;
                }
            }
            //Console.WriteLine(left(0));
            //Console.WriteLine($"{ok} {ook}");
            Console.WriteLine(Math.Max(0,ng-ook));
        }

        bool right(int index)
        {
            for (int i = 0; i < Q; i++)
            {
                if (S[index] == t[i])
                {
                    if (d[i] == 'L')
                    {
                        index--;
                    }
                    else if (d[i] == 'R')
                    {
                        index++;
                    }

                    if (index >= N) return true;
                    if (index < 0) return false;
                }
            }

            return false;
        }

        bool left(int index)
        {
            for (int i = 0; i < Q; i++)
            {
                if (S[index] == t[i])
                {
                    if (d[i] == 'L')
                    {
                        index--;
                    }
                    else if (d[i] == 'R')
                    {
                        index++;
                    }

                    if (index >= N) return false;
                    if (index < 0) return true;
                }
            }

            return false;
        }

        static void Main(string[] args) => new Program().Solve();
    }

    class Scanner
    {
        private char _separator = ' ';
        private StreamReader _stream = new StreamReader(Console.OpenStandardInput());
        private int _pos = 0;
        private string[] _line = new string[0];
        public string Next()
        {
            if (_pos >= _line.Length)
            {
                _line = _stream.ReadLine().Split(_separator);
                _pos = 0;
            }
            return _line[_pos++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public string[] Array()
        {
            if (_pos >= _line.Length)
                _line = _stream.ReadLine().Split(_separator);
            _pos = _line.Length;
            return _line;
        }
        public int[] IntArray()
        {
            var arr = Array();
            var res = new int[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = int.Parse(arr[i]);
            }
            return res;
        }
        public long[] LongArray()
        {
            var arr = Array();
            var res = new long[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = long.Parse(arr[i]);
            }
            return res;
        }
        public double[] DoubleArray()
        {
            var arr = Array();
            var res = new double[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = double.Parse(arr[i]);
            }
            return res;
        }
    }
}
