#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<char> t2;
  t2.reserve(Q);
  vector<int> dir;
  dir.reserve(Q);
  t2.push_back(t[0]);
  dir.push_back((d[0] == 'L') ? -1 : 1);
  int j = 0;
  for (int i = 1; i < Q; ++i) {
    if (t[i - 1] == t[i] && d[i - 1] == d[i]) {
      if (dir[j] < 0)
        dir[j]--;
      else
        dir[j]++;
    } else {
      j++;
      t2.push_back(t[i]);
      dir.push_back((d[i] == 'L') ? -1 : 1);
    }
  }
  vector<vector<int>> pos(256);
  for (int i = 0; i < (int)(N); i++) pos[s[i]].push_back(i);
  vector<int> count(N, 1);
  int res = N;
  for (int i = 0; i < (int)(t2.size()); i++) {
    char c = t2[i];
    int dd = dir[i];
    if (dd < 0) {
      for (auto p : pos[c]) {
        int p_ = p + dd;
        if (p_ < 0) {
          res -= count[p];
          count[p] = 0;
        } else {
          count[p_] += count[p];
          count[p] = 0;
        }
      }
    } else {
      for (int i = pos[c].size() - 1; i >= 0; --i) {
        int p = pos[c][i];
        int p_ = p + dd;
        if (p_ > N - 1) {
          res -= count[p];
          count[p] = 0;
        } else {
          count[p_] += count[p];
          count[p] = 0;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}
