#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  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 ll, rr;
  long long l = 0, r = n - 1;
  long long mid = (l + r) / 2;
  while (l != r) {
    long long now = mid;
    bool flag = true;
    for (long long i = 0; i < q; i++) {
      if (s[now] == t[i]) {
        if (d[i] == 'L')
          now--;
        else
          now++;
      }
      if (now == -1) {
        flag = false;
        break;
      }
    }
    if (flag)
      r = mid;
    else
      l = mid + 1;
    mid = (l + r) / 2;
  }
  ll = mid;
  l = 0;
  r = n;
  mid = (l + r) / 2;
  while (l != r) {
    long long now = mid;
    bool flag = true;
    for (long long i = 0; i < q; i++) {
      if (s[now] == t[i]) {
        if (d[i] == 'L')
          now--;
        else
          now++;
      }
      if (now == n) {
        flag = false;
        break;
      }
    }
    if (flag)
      l = mid + 1;
    else
      r = mid;
    mid = (l + r) / 2;
  }
  rr = mid;
  cout << max((long long)0, rr - ll) << "\n";
  return 0;
}
