#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int INF = 1000000;
const double PI = 3.14159265359;
int main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[q], d[q];
  for (long long i = 0; i < (q); i++) cin >> t[i] >> d[i];
  long long l = -1, r = n;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    long long k = mid;
    for (long long i = 0; i < (q); i++) {
      if (s[k] != t[i]) continue;
      if (d[i] == 'L')
        k--;
      else
        k++;
    }
    if (k < 0)
      l = mid;
    else
      r = mid;
  }
  long long L = r;
  l = -1, r = n;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    long long k = mid;
    for (long long i = 0; i < (q); i++) {
      if (s[k] != t[i]) continue;
      if (d[i] == 'L')
        k--;
      else
        k++;
    }
    if (s.size() <= k)
      r = mid;
    else
      l = mid;
  }
  long long R = n - 1 - l;
  cout << n - (R + L) << endl;
  return 0;
}
