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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<pair<char,char>> td(q);
  for(int i=0;i<q;i++){
    cin >> td[i].first >> td[i].second;
  }
  reverse(all(td));
  int l=0,r=n;
  for(int i=0;i<q;i++){
    if(td[i].second=='L'){
      if(s[l]==td[i].first) l++;
      if(r<n) if(s[r]==td[i].first) r++;
    }else{
      if(l>0) if(s[l-1]==td[i].first) l--;
      if(s[r-1]==td[i].first) r--;
    }
  }
  cout << r-l << endl;
  return 0;
}
