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

int n,q,ans;
char t[200000],d[200000];
string s;

int solve(int x){
    for(int i = 0;i < q;i ++){
        if(s[x]==t[i]) x += d[i]=='R'?1:-1;
        if(x==-1) return 0;
        else if(x==n) return n-1;
    }
    return -1;
}
int binary_search_ans(int ok,int ng,int p){
    while(abs(ok-ng)>1){
        int mid = (ok+ng)/2;
        if(solve(mid)==p){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}

int main(){
    cin >> n >> q >> s;
    for(int i = 0;i < q;i ++){
        cin >> t[i] >> d[i];
    }
    ans += binary_search_ans(-1,n,0)+1;
    ans += n-binary_search_ans(n,-1,n-1);
    cout << n-ans << endl;
    return 0;
}