#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    vector<pair<char, char>> v(Q);
    for(int i=0; i<Q; ++i){
        char t, d; cin >> t >> d;
        v[Q-i-1]=make_pair(t, d);
    }
    int le=-1, ri=N;
    for(int i=0; i<Q; ++i){
        if(le<N) if(S[le+1]==v[i].first && v[i].second=='L') ++le;
        if(le>-1) if(S[le]==v[i].first && v[i].second=='R') --le;
        if(ri<N) if(S[ri]==v[i].first && v[i].second=='L') ++ri;
        if(ri>0) if(S[ri-1]==v[i].first && v[i].second=='R') --ri;
    }
    cout << max(0, ri-le-1) << endl;
    return 0;
}
