#include <bits/stdc++.h>
using namespace std;
const int INF = 1e+9;
const long long INFLL = 1e+17;
int n, q;
char s[200010], t[200010], d[200010];
int main() {
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < q; i++) {
    cin >> t[q - 1 - i] >> d[q - 1 - i];
  }
  int j = 0;
  int cnt = 0, res = 0;
  bool f = false;
  for (int i = 0; i < q; i++) {
    if (t[i] == s[0] && d[i] == 'L') {
      f = true;
    }
    if (f && t[i] == s[j] && d[i] == 'R') {
      res = max(res, cnt);
      f = false;
      j = 0;
      cnt = 0;
    } else if (f && t[i] == s[j + 1] && d[i] == 'L') {
      cnt++;
      j++;
    }
  }
  int res1;
  if (f) res1 = max(cnt + 1, res);
  cnt = 0;
  res = 0;
  j = q - 1;
  f = false;
  for (int i = 0; i < q; i++) {
    if (t[i] == s[n - 1] && d[i] == 'R') {
      f = true;
    }
    if (f && t[i] == s[j] && d[i] == 'L') {
      res = max(res, cnt);
      f = false;
      j = q - 1;
      cnt = 0;
    } else if (f && t[i] == s[j - 1] && d[i] == 'R') {
      cnt++;
      j--;
    }
  }
  int res2;
  if (f) res2 = max(cnt + 1, res);
  cout << n - res1 - res2 << "\n";
  return 0;
}
