#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main() {
    int N,Q;
    cin>>N>>Q;
    string s;
    cin>>s;
    
    vector<char> t(Q),d(Q);
    for(int i=0;i<Q;i++){
        cin>>t[i]>>d[i];
    }
    int left=-1,right=N;
    for(int i=Q-1;i>=0;i--){
        if(d[i]=='L'&&t[i]==s[left+1]) left++;
        if(d[i]=='R'&&t[i]==s[right-1]) right--;
        if(d[i]=='L'&&t[i]==s[right]) right++;
        if(d[i]=='R'&&t[i]==s[left]) left--;
        
    }
    cout<<max(0,right-left-1)<<endl;
}