#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
vector<char> t(q), d(q);
int solve(int pos) {
  for (int i = 0; i < q; ++i) {
    if (s[pos] == t[i]) {
      if (d[i] == 'R') {
        pos++;
      } else {
        pos--;
      }
    }
    if (pos == -1) return -1;
    if (pos == n) return 1;
  }
  return 0;
}
int main(void) {
  cin >> n >> q >> s;
  t.resize(q);
  d.resize(q);
  for (int i = 0; i < q; ++i) {
    cin >> t[i] >> d[i];
  }
  int ok = 0;
  int ng = n - 1;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (solve(mid) == -1) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  int l = (solve(ok) == -1) ? ok : ok - 1;
  ok = n - 1;
  ng = 0;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (solve(mid) == 1) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  int r = (solve(ok) == 1) ? ok : ok + 1;
  cout << r - l - 1 << endl;
  return 0;
}
