#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {

  int N, Q;
  string s;
  cin >> N >> Q >> s;
  vector<char> t(Q), d(Q);
  for (int i=Q-1; i>=0; i--) {
    cin >> t[i] >> d[i];
  }
  
  int li, ri;
  li = 0;
  ri = N-1;
  for (int i=0; i<Q; i++) {
    if (d[i] == 'L'){
      if (s[li] == t[i])
        li++;
      if (ri<N-1 && s[ri+1] == t[i])
        ri++;
    }else{
      if (s[ri] == t[i])
        ri--;
      if (li>0 && s[li-1] == t[i])
        li--;
    }
  }
  cout << max(ri - li + 1, 0) << endl;
  
  return 0;
}