#include<iostream>
#include<cmath>
#include<string>
using namespace std;

//input
int N, Q;
string s;
char t[200020];
char d[200020];

bool isOK(int idx, int dst) {
    for (int i = 0; i < Q; ++i) {
        if (s[idx] == t[i]) {
            if (d[i] == 'R') ++idx;
            else --idx;
        }
        if (idx == dst) return true;
        else if (idx == -1 || idx == N) return false; 
    }
    return false;
}

int bisection(int dst) {
    int ng = N + (-1) - dst;
    int ok = dst;

    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (isOK(mid, dst)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    cin >> N >> Q;
    cin >> s;
    for (int i = 0; i < Q; ++i) cin >> t[i] >> d[i];

    int r = bisection(-1);
    int l = bisection(N);

    if (l <= r) cout << 0 << endl;
    else cout << N - (N - l) - (r + 1) << endl;

}