#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll n,q;
char t[200020],d[200020];
int solt(ll x){
    for(int i = 0; i < q; i++){
        if(s[x] == t[i]){
            if(d[i] == 'L') x--;
            if(d[i] == 'R') x++;
        }
        if(x == -1) return 1;
        if(x == n) return 2;
    }
    return 0;
}
int main(){
    cin >> n >> q >> s;
    for(int i = 0; i < q; i++){
        cin >> t[i] >> d[i];
    }
    ll mid;
    ll ls = -1; 
    ll rs = n;
    while(ls < rs-1){
        mid = (ls + rs)/2;
        if(solt(mid) == 1) ls = mid;
        else rs = mid;
    }
    ll lt = -1;
    ll rt = n;
    while(lt < ls-1){
        mid = (lt+rs)/2;
        if(solt(mid) == 2) rt = mid;
        else lt = mid;
    }
    cout << rt - ls - 1 << endl;
    return 0;
}

