#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const long long MOD = (long long)1000000007;
const long long INF2 = (long long)100000000000000000;
int main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> alpha(q);
  vector<char> d(q);
  for (int i = 0; i < q; i++) {
    char x, y;
    cin >> x >> y;
    alpha[i] = x;
    d[i] = y;
  }
  char prev = s[n - 1];
  long long cnt = 0;
  long long cl = 0;
  long long idx = n - 2;
  long long found = -1;
  for (int i = q - 1; i >= 0; i--) {
    if (alpha[i] == prev && d[i] == 'R') {
      found = i;
      cnt = 1;
      cl = 1;
      break;
    }
  }
  for (int i = found - 1; i >= 1; i--) {
    if (alpha[i] == prev && d[i] == 'L') {
      prev = s[n - 1];
      cl = max(cl, cnt);
      cnt = 0;
      idx = n - 2;
    }
    if (idx < 0) continue;
    if (alpha[i] == s[idx] && d[i] == 'R') {
      cnt++;
      prev = s[idx];
      cl = max(cl, cnt);
      idx--;
    }
  }
  found = -1;
  prev = s[0];
  cnt = 0;
  idx = 1;
  long long cr = 0;
  for (int i = q - 1; i >= 0; i--) {
    if (alpha[i] == prev && d[i] == 'L') {
      found = i;
      cnt = 1;
      cr = 1;
      break;
    }
  }
  for (int i = found - 1; i >= 1; i--) {
    if (alpha[i] == prev && d[i] == 'R') {
      prev = s[0];
      cr = max(cr, cnt);
      cnt = 0;
      idx = 1;
    }
    if (idx >= n) continue;
    if (alpha[i] == s[idx] && d[i] == 'L') {
      cnt++;
      prev = s[idx];
      cr = max(cr, cnt);
      idx++;
    }
  }
  long long ans = max(n - cl - cr, 0LL);
  cout << ans << endl;
  return 0;
}
