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

public class Solution
{
    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];
        }

        int golem = s.Length;
        for (int i = 0; i < s.Length; i++)
        {
            var p = i;
            for (int j = 0; j < q; j++)
            {
                var c = t[j];
                if(s[p] == c)
                {
                    if(dir[j] == 'L')
                    {
                        p--;
                        if(p < 0)
                        {
                            golem--;
                            break;
                        }
                    }
                    else
                    {
                        p++;
                        if(p >= n)
                        {
                            golem--;
                            break;
                        }
                    }
                }
            }
        }

        Console.WriteLine(golem);
    }
}