#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
char t[200000], d[200000];
vector<int> v;
void f(int x, int y) {
  cout << x << " " << y << endl;
  for (int i = y; i >= 0; i--) {
    cout << "x,i : " << x << " " << i << endl;
    if (x >= 0 && x <= n - 1 && t[i] == s[x]) return;
    if (x + 1 <= n - 1) {
      if (d[i] == 'L' && t[i] == s[x + 1]) {
        f(x + 1, i - 1);
      }
    }
    if (x - 1 >= 0) {
      if (d[i] == 'R' && t[i] == s[x - 1]) {
        f(x - 1, i - 1);
      }
    }
  }
  if (x >= 0 && x < n) v.push_back(x);
  cout << "in " << x << endl;
}
int main(void) {
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  f(-1, q - 1);
  f(n, q - 1);
  sort(v.begin(), v.end());
  int a = n;
  for (int i = 0; i < v.size(); i++) {
    if (i > 0 && v[i] == v[i - 1]) continue;
    a--;
  }
  cout << a << endl;
}
