#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T itr1, T itr2) {
  auto now = itr1;
  while (now < itr2) {
    cout << *now << " ";
    now++;
  }
  cout << endl;
}
const long long MOD = pow(10, 9) + 7;
const long long LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  s = "x" + s + "x";
  char t[Q], d[Q];
  for (int i = (int)0; i < (int)Q; i++) cin >> t[i] >> d[i];
  long long result = N;
  long long l = 0, r = N + 2;
  while (l != r) {
    long long mid = (l + r + 1) / 2;
    long long pos = mid;
    bool ok = false;
    for (int i = (int)0; i < (int)Q; i++) {
      if (s[pos] == t[i]) pos += d[i] == 'L' ? -1 : 1;
      if (pos == 0) {
        ok = true;
        break;
      } else if (pos == N + 1)
        break;
    }
    if (ok)
      l = mid;
    else
      r = mid - 1;
  }
  result -= l;
  l = 0;
  r = N + 2;
  while (l != r) {
    long long mid = (l + r) / 2;
    long long pos = mid;
    bool ok = false;
    for (int i = (int)0; i < (int)N; i++) {
      if (s[pos] == t[i]) pos += d[i] == 'L' ? -1 : 1;
      if (pos == 0)
        break;
      else if (pos == N + 1) {
        ok = true;
        break;
      }
    }
    if (ok)
      r = mid;
    else
      l = mid + 1;
  }
  result -= (N + 1) - l;
  cout << result << endl;
  return 0;
}
