#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, q;
string s;
char t[200000], d[200000];
int main(void){
    cin>>n>>q>>s;
    for(int i=0;i<q;i++){
        cin>>t[i]>>d[i];
    }
    int l=-1, r=n;
    for(int i=q-1;i>=0;i--){
        if(l+1<=n+1){
            if(d[i]=='L'&&t[i]==s[l+1]){
                l++;
            }
        }
        if(d[i]=='R'&&t[i]==s[l])l--;
        if(r-1>=0){
            if(d[i]=='R'&&t[i]==s[r-1]){
                r--;
            }
        }
        if(d[i]=='L'&&t[i]==s[r])r++;
    }
    cout<<max(0, n-max(0, l+1)-max(0, n-r))<<endl;
}
