#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  vector<char> s(n);
  for (int i = 0; i < n; i++) cin >> s.at(i);
  vector<char> t(q), d(q);
  for (int i = 0; i < q; i++) cin >> t.at(i) >> d.at(i);
  vector<int> gorem(n);
  for (int i = 0; i < n; i++) gorem.at(i) = 1;
  for (int i = 0; i < q; i++) {
    if (d.at(i) == 'L') {
      for (int j = 0; j < n; j++) {
        if (t.at(i) == s.at(j)) {
          if (j == 0) {
            gorem.at(j) = 0;
          } else {
            gorem.at(j - 1) += gorem.at(j);
            gorem.at(j) = 0;
          }
        }
      }
    } else if (d.at(i) == 'R') {
      for (int j = n - 1; j >= 0; j--) {
        if (t.at(i) == s.at(j)) {
          if (j == n - 1) {
            gorem.at(j) = 0;
          } else {
            gorem.at(j + 1) += gorem.at(j);
            gorem.at(j) = 0;
          }
        }
      }
    }
  }
  int result = 0;
  for (int i = 0; i < n; i++) result += gorem.at(i);
  cout << result;
}
