#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;
char t[110000], d[110000];
int N, Q;
string s;
int sim(int idx) {
  for (long long(i) = (0); (i) < (Q); ++i) {
    if (s[idx] == t[i]) {
      if (d[i] == 'L')
        idx--;
      else
        idx++;
    }
    if (idx < 0 || idx >= N) return idx;
  }
  return idx;
}
int main() {
  cin >> N >> Q;
  cin >> s;
  for (long long(i) = (0); (i) < (Q); ++i) cin >> t[i] >> d[i];
  int l, r;
  int cnt = 0;
  l = -1, r = N;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (sim(mid) >= N)
      r = mid;
    else
      l = mid;
  }
  cnt += N - r;
  l = -1, r = N;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (sim(mid) < 0)
      l = mid;
    else
      r = mid;
  }
  cnt += l + 1;
  cout << (N - cnt) << endl;
  return 0;
}
