#include <iostream>

using namespace std;

int main(){
    int N, Q;
    string s;
    char t[200000];
    char d[200000];
    cin >> N >> Q;
    cin >> s;
    for(int i = 0; i < Q; i++){
        cin >> t[i] >> d[i];
    }
    int l = -1;
    int r = N;
    for(int i = Q-1; i >= 0; i--){
        if(l == -1){
            if(t[i] == s[0] && d[i] == 'L') l = 0;
        }else{
            if(t[i] == s[l] && d[i] == 'R') l--;
            if(t[i] == s[l+1] && d[i] == 'L') l++;
        }
    }
    for(int i = Q-1; i >= 0; i--){
        if(r == N){
            if(t[i] == s[N-1] && d[i] == 'R') r = N-1;
        }else{
            if(t[i] == s[r] && d[i] == 'L') r++;
            if(t[i] == s[r-1] && d[i] == 'R') r--;
        }
    }
    //cout << l << ' ' << r << endl;
    if(l >= r) cout << 0 << endl;
    else cout << r-l-1 << endl;
}