#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  char a, b;
  vector<pair<char, char> > p(m);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    p[i] = pair<char, char>(a, b);
  }
  int x = 0, y = n - 1;
  char l = s[x], r = s[y];
  int lin = 0, rin = 0;
  reverse(p.begin(), p.end());
  for (int i = 0; i < m; i++) {
    if (p[i].first == l && p[i].second == 'L') {
      if (l == r) {
        rin = max(rin - 1, 0);
      }
      lin++;
      if (lin == n) {
        cout << 0;
        return 0;
      }
      l = s[++x];
    } else if (p[i].first == r && p[i].second == 'R') {
      if (l == r) lin = max(lin - 1, 0);
      rin++;
      if (rin == n) {
        cout << 0;
        return 0;
      }
      r = s[--y];
    }
  }
  cout << max(0, n - lin - rin);
}
