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

public class Solution
{
    static int Solve(string s, int i, char[] t, char[] dir)
    {
        var n = s.Length;
        var p = i;
        for (int j = 0; j < t.Length; j++)
        {
            var c = t[j];
            if (s[p] == c)
            {
                if (dir[j] == 'L')
                {
                    p--;
                    if (p < 0)
                    {
                        return -1;
                    }
                }
                else
                {
                    p++;
                    if (p >= n)
                    {
                        return 1;
                    }
                }
            }
        }
        return 0;
    }

    // [ok,ng) or (ng,ok]
    static int Search(string s, int ok, int ng, char[] t, char[] dir)
    {
        while (Math.Abs(ok - ng) > 1)
        {
            var mid = (ok + ng) / 2;
            if (Solve(s, mid, t, dir) == 0)
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }
        return ok;
    }

    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = vals[0];
        var q = vals[1];
        var s = Console.ReadLine();
        var t = new char[q];
        var dir = new char[q];
        for (int i = 0; i < q; i++)
        {
            var strs = Console.ReadLine().Split(' ');
            t[i] = strs[0][0];
            dir[i] = strs[1][0];
        }

        var max = Search(s, 0, n, t, dir);
        var min = Search(s, n, 0, t, dir);

        Console.WriteLine(max - min + 1);
    }
}