/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

int n,q,vis[202020];
string s;
char t[202020],d[202020];

int fnd( int st, char c, char chh){
       int lc = 0,rc=0;
       int res = 0;
       //cout << st << endl;
       for(int i=st;i>=1;i--){
              if(t[i]==c){
                     if(d[i]==chh)lc++;
                     else rc++;
                     if(lc>=rc)return i;
              }
       }
       return res;
}
int fnd1( int st, char c, char chh){
       int lc = 0,rc=0;
       int res = 0;
       //cout << st << " " << c << " " << chh << endl;
       for(int i=st;i>=1;i--){
              if(t[i]==c){
                     if(d[i]==chh)lc++;
                     else rc++;
                     if(lc>=rc)return i;
              }
       }
       return res;
}

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

cin >> n >> q;
cin >> s;
for(int i=1;i<=q;i++){
       cin >> t[i] >> d[i];
}
char cur = s[0];
int l = 0;

for(int i=q;i>=1;i--){
       if(d[i]=='L'&&t[i]==cur){
              l = i;
              break;
       }
}
//cout << l << endl;
if(l){
       vis[0]=1;
       int c = 1;
       while(l>0 && c<n ){
  //            cout << l << endl;
              l = fnd(l-1, s[c], 'L' );
              //cout << l << endl;
              if(l>0){
                     vis[c]=1;
                     c++;
              }
              else break;
       }
}

cur = s[n-1];
l = 0;
for(int i=q;i>=1;i--){
       if(d[i]=='R'&&t[i]==cur){
              l = i;
              break;
       }
}
//cout << l << endl;
if(l){
       vis[n-1]=1;
       int c = n-2;
       while(l>0 && c>=0 ){
  //            cout << l << endl;
              l = fnd1(l-1, s[c], 'R' );
    //          cout << l << endl;
              if(l>0){
                     vis[c]=1;
                     c--;
              }
              else break;
       }
}

int ans = 0;
for(int i=0;i<n;i++){
       if(vis[i])ans++;
}
cout << n-ans << endl;

return 0;
}
///....
