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

int main() {
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  char t[200005],d[200005];
  for (int i=0; i<q; i++) {
    cin>>t[i]>>d[i];
  }

  int mid,lo=-1,hi=n,left,right;
  while (hi-lo>1) {
    mid=(lo+hi)/2;
    int pos=mid;
    for (int i=0; i<q; i++) {
      if (s[pos]==t[i]) {
	if (d[i]=='L') pos--;
	else pos++;
	if (pos<0||pos>=n) break;
      }
    }
    if (pos<0) lo=mid;
    else hi=mid;
  }
  left=hi;
  
  lo=-1;
  hi=n;
  while (hi-lo>1) {
    mid=(lo+hi)/2;
    int pos=mid;
    for (int i=0; i<q; i++) {
      if (s[pos]==t[i]) {
	if (d[i]=='L') pos--;
	else pos++;
	if (pos<0||pos>=n) break;
      }
    }
    if (pos>=n) hi=mid;
    else lo=mid;
  }
  right=lo;
  
  cout<<max(0,right-left+1)<<endl;
  return 0;
}