#include <bits/stdc++.h>
using namespace std;
int chkdir(int p, string s, vector<pair<char, char> > arr) {
  int n = s.length(), q = arr.size();
  for (int i = 0; i < q; ++i) {
    if (s[p] == arr[i].first) {
      p += (arr[i].second == 'R' ? 1 : -1);
      if (p < 0) return -1;
      if (n <= p) return 1;
    }
  }
  return 0;
}
int binsrc(int dir, string s, vector<pair<char, char> > arr) {
  int n = s.length(), head = 0, tail = n - 1;
  while (tail - head) {
    if (tail - head == 1) {
      bool h = false, t = false;
      h = (chkdir(head, s, arr) == dir);
      t = (chkdir(tail, s, arr) == dir);
      if (!(h || t)) return (dir == 1 ? n : -1);
      if (dir == 1) return (h ? head : tail);
      if (dir == -1) return (t ? tail : head);
    }
    if (chkdir(((head + tail) / 2), s, arr) == dir)
      (dir == 1 ? tail : head) = ((head + tail) / 2);
    else
      (dir == 1 ? head : tail) = ((head + tail) / 2) + (dir == 1 ? 1 : -1);
  }
  if (chkdir(head, s, arr) == dir)
    return head;
  else
    return (dir == 1 ? n : -1);
}
int main() {
  int n, q, res = 0;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, char> > v(q);
  for (int i = 0; i < q; ++i) cin >> v[i].first >> v[i].second;
  for (int i = 0; i < n; ++i)
    if (chkdir(i, s, v) == 0) res++;
  cout << res << endl;
  return 0;
}
