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];
        }

        var state = Enumerable.Repeat(1, n).ToArray();
        for (int i = 0; i < q; i++)
        {
            var c = t[i];
            if (dir[i] == 'L')
            {
                if (s[0] == c)
                {
                    state[0] = 0;
                }
                for (int j = 1; j < s.Length; j++)
                {
                    if (s[j] == c)
                    {
                        state[j - 1] += state[j];
                        state[j] = 0;
                    }
                }
            }
            else
            {
                if (s[n - 1] == c)
                {
                    state[n - 1] = 0;
                }
                for (int j = n - 2; j >= 0; j--)
                {
                    if (s[j] == c)
                    {
                        state[j + 1] += state[j];
                        state[j] = 0;
                    }
                }
            }
        }

        Console.WriteLine(state.Sum());
    }
}