#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void) {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char* t = new char[q];
  char* d = new char[q];
  char* g = new char[n];
  for (int i = 0; i < q; ++i) {
    cin >> t[i] >> d[i];
  }
  int cnt = n;
  int p;
  char c;
  for (int si = 0; si < n; ++si) {
    p = si;
    c = s[si];
    for (size_t ti = 0; ti < q; ++ti) {
      if (c == t[ti]) {
        if (d[ti] == 'L') {
          --p;
        } else {
          ++p;
        }
        if (p < 0 || p >= n) {
          cnt--;
          break;
        } else {
          c = s[p];
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
