#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
int n, q;
string s;
string t;
string d;
bool ok(int x) {
  for (int i = 0; i < q; ++i) {
    if (d[i] == 'L') {
      if (s[x] == t[i]) --x;
      if (x < 0) return false;
    } else {
      if (s[x] == t[i]) ++x;
      if (x >= n) return false;
    }
  }
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  cin >> s;
  t.resize(q);
  d.resize(q);
  for (int i = 0; i < q; ++i) {
    cin >> t[i] >> d[i];
  }
  int ans = n;
  int l, r;
  l = -1;
  r = n;
  while (l + 1 < r) {
    int m = (l + r) / 2;
    if (ok(m))
      r = m;
    else
      l = m;
  }
  ans -= r;
  l = -1;
  r = n;
  while (l + 1 < r) {
    int m = (l + r) / 2;
    if (ok(m))
      l = m;
    else
      r = m;
  }
  ans -= n - l - 1;
  cout << ans << "\n";
  return 0;
}
