#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[q], d[q];
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  if (n == 1) {
    for (int i = 0; i < q; i++) {
      if (t[i] == s[0]) cout << 0 << endl;
      return 0;
    }
    cout << 1 << endl;
    return 0;
  }
  int ul = n, dl = -1;
  while (ul - dl > 1) {
    int mid = (ul + dl) / 2;
    int now = mid;
    for (int i = 0; i < q; i++) {
      if (s[now] == t[i] && d[i] == 'L') {
        now--;
      } else if (s[now] == t[i] && d[i] == 'R')
        now++;
      if (now == -1) break;
      if (now == n - 1) break;
    }
    if (now == -1)
      dl = mid;
    else
      ul = mid;
  }
  int ur = n, dr = -1;
  while (ur - dr > 1) {
    int mid = (ur + dr) / 2;
    int now = mid;
    for (int i = 0; i < q; i++) {
      if (s[now] == t[i] && d[i] == 'R') {
        now++;
      } else if (s[now] == t[i] && d[i] == 'L')
        now--;
      if (now == n) break;
      if (now == -1) break;
    }
    if (now == n)
      ur = mid;
    else
      dr = mid;
  }
  int sum = min(n, ul + n - 1 - dr);
  cout << n - sum << endl;
}
