#include <iostream>
#include <vector>
#include <string>

using namespace std;

struct move
{
    char ch, direction;

    move(){}

    move(char C, char D)
    {
        ch = C, direction = D;
    }
};

int displacement(string &S, int position, vector <move> &M)
{ //cout << position << " final = ";
    for(int i = 1; i < M.size(); i++)
    {
        if(S[position] == M[i].ch)
        {
            position += (M[i].direction == 'L' ? -1 : 1);
        }

        if(position == 0 || position == S.size() - 1)
        {
            break;
        }
    }// cout << position << endl;

    return position;
}

int main()
{
    int length, no_of_moves;
    string S;
    cin >> length >> no_of_moves >> S;

    S = '*' + S + '*';

    vector <move> moves(no_of_moves + 1);
    for(int i = 1; i <= no_of_moves; i++)
    {
        cin >> moves[i].ch >> moves[i].direction;
    }

    int left = 0, right = length + 1;
    while(right - left > 1)
    {
        int mid = (left + right)/2;

        if(displacement(S, mid, moves) == 0)
        {
            left = mid;
        }
        else
        {
            right = mid;
        }
    }
    int rightmost_to_fall_left = left; //cout << "R = " << rightmost_to_fall_left << endl;

    left = 0, right = length;
    while(right - left > 1)
    {
        int mid = (left + right)/2;

        if(displacement(S, mid, moves) == length + 1)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }
    int leftmost_to_fall_right = right; //cout << "L = " << leftmost_to_fall_right << endl;

    int remaining = (leftmost_to_fall_right - 1) - rightmost_to_fall_left;
    cout << remaining;

    return 0;
}
