#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int n, q;
string s;
int main() {
  cin >> n >> q;
  cin >> s;
  vector<char> t(q);
  vector<char> d(q);
  for (long long i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  vector<int> l(q + 1);
  vector<int> r(q + 1);
  l[q] = 0;
  r[q] = 0;
  int maxl = 0;
  int maxr = 0;
  bool fl = true;
  bool fr = true;
  for (int i = q - 1; i >= 0; --i) {
    l[i] = l[i + 1];
    r[i] = r[i + 1];
    if (d[i] == 'L') {
      if (t[i] == s[l[i]] && fl) {
        l[i]++;
        chmax(maxl, l[i]);
      }
      if (r[i] > 0) {
        if (t[i] == s[n - r[i]]) {
          fr = false;
        }
      }
    } else {
      if (t[i] == s[n - 1 - r[i]] && fr) {
        r[i]++;
        chmax(maxr, r[i]);
      }
      if (l[i] > 0) {
        if (t[i] == s[l[i] - 1]) {
          fl = false;
        }
      }
    }
  }
  int res = max(n - maxr - maxl, 0);
  cout << res << endl;
  ;
  return 0;
}
