#include <bits/stdc++.h>
using namespace std;
pair<string, string> td[200005];
string s;
int n, q;
bool solve(int k) {
  for (int i = 0; i < q; i++) {
    if (s[k] == td[i].first[0]) {
      if (td[i].second == "R") {
        k++;
      } else {
        k--;
      }
    }
  }
  if (k == 0 || k == n + 1) {
    return true;
  }
  return false;
}
int main() {
  cin >> n >> q;
  cin >> s;
  s = "*" + s + "*";
  for (int i = 0; i < q; i++) {
    string t, d;
    cin >> t >> d;
    td[i] = make_pair(t, d);
  }
  int left = 0, mid = 0;
  int ng = 0, ok = n + 1;
  while (abs(ok - ng) > 1) {
    mid = (ok + ng) / 2;
    if (solve(mid)) {
      ng = mid;
    } else {
      ok = mid;
    }
  }
  left = ok;
  int right = 0;
  ng = n + 1;
  ok = 0;
  while (abs(ok - ng) > 1) {
    mid = (ok + ng) / 2;
    if (solve(mid)) {
      ng = mid;
    } else {
      ok = mid;
    }
  }
  right = ok;
  cout << right - left + 1 << endl;
}
