#include <bits/stdc++.h>
using namespace std;
const int64_t INF = 1000000000000000000;
int64_t pw(int64_t x, int64_t y) {
  int64_t r = 1;
  for (int64_t i = (0); i < (y); ++i) {
    r *= x;
  };
  return r;
}
int main() {
  int64_t N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q), d(Q);
  for (int64_t i = (0); i < (Q); ++i) cin >> t[i] >> d[i];
  map<char, vector<int64_t> > g_map;
  for (int64_t i = (0); i < (N); ++i) g_map[s[i]].push_back(i);
  vector<int64_t> grem(N, 1);
  for (int64_t i = (0); i < (Q); ++i) {
    if (d[i] == 'L') {
      for (int64_t j = (0); j < (g_map[t[i]].size()); ++j) {
        int64_t tmp = grem[g_map[t[i]][j]];
        grem[g_map[t[i]][j]] = 0;
        if (g_map[t[i]][j] != 0) grem[g_map[t[i]][j] - 1] += tmp;
      }
    } else {
      for (int64_t j = (0); j < (g_map[t[i]].size()); ++j) {
        int64_t tmp = grem[g_map[t[i]][j]];
        grem[g_map[t[i]][j]] = 0;
        if (g_map[t[i]][j] != N - 1) grem[g_map[t[i]][j] + 1] += tmp;
      }
    }
  }
  cout << accumulate((grem).begin(), (grem).end(), 0) << endl;
}
