#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q);
  vector<char> d(Q);
  for (int i = 0; i < (int)(Q); i++) cin >> t[i] >> d[i];
  vector<int> pos(N);
  for (int i = 0; i < (int)(N); i++) pos[i] = i;
  int b[256] = {0};
  for (int i = 0; i < (int)(256); i++) {
    b[s[i]] = 1;
  }
  vector<vector<int>> ii(256);
  for (int i = 0; i < (int)(N); i++) {
    if (b[s[i]]) ii[s[i]].reserve(30000);
  }
  for (int i = 0; i < (int)(N); i++) {
    ii[s[i]].push_back(i);
  }
  for (int i = 0; i < (int)(Q); i++) {
    char c = t[i];
    int dir = (d[i] == 'L') ? -1 : 1;
    vector<int> new_ii;
    new_ii.reserve(30000);
    for (int j = 0; j < (int)(ii[c].size()); j++) {
      int pos = ii[c][j] + dir;
      if (pos < 0 || pos > N - 1) continue;
      char c_next = s[pos];
      if (c == c_next)
        new_ii.push_back(pos);
      else
        ii[c_next].push_back(pos);
    }
    ii[c] = new_ii;
  }
  int res = 0;
  for (auto iii : ii) {
    res += iii.size();
  }
  cout << res << endl;
  return 0;
}
