#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

#define MOD 1000000007
using ll = long long;
using namespace std;

int N, Q;
string S;
vector<char> t, d;

int isDel(int now) {
    for (int i = 0; i < Q; i++)
    {
        if (now != -1 && now != N && S[now] == t[i]) {
            if (d[i] == 'L') {
                now--;
            }
            else {
                now++;
            }
        }
    }
    if (now == -1) {
        return -1;
    }
    else if (now == N) {
        return 1;
    }
    else {
        return 0;
    }
}

int main() {
    cin >> N >> Q >> S;
    for (int i = 0; i < Q; i++)
    {
        char a, b;
        cin >> a >> b;
        t.push_back(a);
        d.push_back(b);
    }
    // Find the left edge
    int left = 0, right = N;
    while (right - left > 1) {
        int mid = (left + right) / 2;
        if (isDel(mid) >= 0) {
            right = mid;
        }
        else {
            left = mid;
        }
    }
    int LE = right;
    // Find the right edge
    left = 0, right = N;
    while (right - left > 1) {
        int mid = (left + right) / 2;
        if (isDel(mid) <= 0) {
            left = mid;
        }
        else {
            right = mid;
        }
    }
    int RE = left;
    cout << RE - LE + 1 << endl;
    cin >> <>;
    return 0;
}