#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, Q;
  string s;
  cin >> N >> Q >> s;
  vector<char> T(Q);
  vector<char> D(Q);
  for (int i = 0; i < Q; i++) cin >> T[i] >> D[i];
  int l, r;
  l = 0, r = N + 1;
  for (int i = Q - 1; i >= 0; i--) {
    if (D[i] == 'L') {
      if (s[l] == T[i]) {
        l++;
      }
    } else {
      if (s[r - 2] == T[i]) {
        r--;
      }
    }
    if (r - l - 1 == 0) {
      break;
    }
  }
  cout << r - l - 1 << endl;
}
