#include <bits/stdc++.h>
using namespace std;
using vecint = vector<int>;
using ll = int64_t;
int pos(const string& s, const string& t, const vector<bool>& dir, int i) {
  int q = t.size();
  for (int j = (0); j < (q); ++j) {
    if (s[i] == t[j]) {
      if (dir[j]) {
        --i;
      } else {
        ++i;
      }
    }
  }
  return i;
}
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  string t;
  vector<bool> dir(n);
  for (int i = (0); i < (q); ++i) {
    string c;
    string d;
    cin >> c >> d;
    t.push_back(c[0]);
    dir[i] = d[0] == 'L';
  }
  s = "$" + s + "$";
  int lo = 0;
  int hi = n + 1;
  while (hi - lo > 1) {
    int mid = (hi + lo) / 2;
    if (pos(s, t, dir, mid) == 0) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  int left = lo;
  lo = 0;
  hi = n + 1;
  while (hi - lo > 1) {
    int mid = (hi + lo) / 2;
    if (pos(s, t, dir, mid) == n + 1) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  int right = n + 1 - hi;
  cout << (n - left - right) << endl;
  return 0;
}
