#include <bits/stdc++.h>
using namespace std;
int N,Q;
string S;
vector<char> t,d;

int C(int n) {
    for(int i=0; i<Q; ++i) {
        if(t[i] == S[n]) n += (d[i] == 'R' ? 1 : -1);
    }

    if(n == 0) return -1;
    else if(n == N + 1) return 1;
    else return 0;
}

int solveL() {
    int l = 0, r = N + 1;
    while(r - l > 1) {
        int m = (l + r) / 2;
        if(C(m) == -1) l = m;
        else r = m;
    }
    return l;
}

int solveR() {
    int l = 0, r = N + 1;
    while(r - l > 1) {
        int m = (l + r) / 2;
        if(C(m) == 1) r = m;
        else l = m;
    }
    return r;
}

int main() {
    cin >> N >> Q;
    cin >> S;
    S = '!' + S;
    S += '!';
    t.resize(Q);
    d.resize(Q);
    for(int i=0; i<Q; ++i) cin >> t[i] >> d[i];

    int left = solveL();
    int right = solveR();
    cout << right - 1 - left << endl;
}