#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
signed main() {
  long long n, Q;
  string s;
  cin >> n >> Q >> s;
  vector<char> t(Q), d(Q);
  for (long long i = (long long)(0); i < (long long)(Q); i++) {
    cin >> t[i] >> d[i];
  }
  reverse((t).begin(), (t).end());
  reverse((d).begin(), (d).end());
  long long ans = 0;
  long long cur = 0, cnt = 0;
  for (long long i = (long long)(0); i < (long long)(Q); i++) {
    if (s[cur] == t[i] and d[i] == 'L') {
      cnt = 0;
      cur++;
      if (cur == n) break;
    }
    if (cur > 0 and s[cur - 1] == t[i] and d[i] == 'R') {
      cnt = 1;
    }
  }
  ans += cur - cnt;
  cur = 0, cnt = 0;
  for (long long i = (long long)(0); i < (long long)(Q); i++) {
    if (s[n - 1 - cur] == t[i] and d[i] == 'R') {
      cnt = 0;
      cur++;
      if (cur == n) break;
    }
    if (cur > 0 and s[n - 1 - cur + 1] == t[i] and d[i] == 'L') {
      cnt = 1;
    }
  }
  ans += cur - cnt;
  if (ans > n) ans = n;
  cout << n - ans << endl;
  return 0;
}
