#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q), d(Q);
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  bool lstart = false;
  int lans = 0;
  int ltmp = 0;
  bool rstart = false;
  int rans = N - 1;
  int rtmp = N - 1;
  for (int i = Q - 1; i >= 0; i--) {
    if (t[i] == s[0] and d[i] == 'L') {
      lstart = true;
      lans = max(lans, ltmp);
      ltmp = 0;
    } else {
      if (!lstart) continue;
      if (s[ltmp + 1] == t[i] and d[i] == 'L') {
        ltmp++;
      } else if (s[ltmp - 1] == t[i] and d[i] == 'R') {
        ltmp;
      }
    }
  }
  lans = max(lans, ltmp);
  for (int i = Q - 1; i >= 0; i--) {
    if (t[i] == s[N - 1] and d[i] == 'R') {
      rstart = true;
      rans = min(rans, rtmp);
      rtmp = N - 1;
    } else {
      if (!rstart) continue;
      if (s[rtmp + 1] == t[i] and d[i] == 'L') {
        rtmp;
      } else if (s[rtmp - 1] == t[i] and d[i] == 'R') {
        rtmp--;
      }
    }
  }
  rans = min(rans, rtmp);
  if (!lstart) lans--;
  if (!rstart) rans++;
  cout << rans - lans - 1 << endl;
  return 0;
}
