#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
const int N=2e5+5;
int n,t;
char a[N];
pair<char,char>q[N];
int main()
{
    scanf("%d%d",&n,&t);
    forn(i,1,n){
        scanf(" %c",&a[i]);
    }
    forn(i,1,t){
        scanf(" %c %c",&q[i].f,&q[i].s);
    }
    int l=1,r=n;
    ford(i,t,1){
        if(q[i].f==a[l]&&q[i].s=='L'){
            l++;
        }
        else if(q[i].f==a[l-1]&&q[i].s=='R'){
            l--;
        }
        if(q[i].f==a[r]&&q[i].s=='R'){
            r--;
        }
        else if(q[i].f==a[r+1]&&q[i].s=='L'){
            r++;
        }
    }
    printf("%d\n",max(0,r-l+1));
    return 0;
}
