#include <bits/stdc++.h>
using namespace std;
map<int, int> dp;
unsigned long H, W;
void find_all(const std::string str, const char target, vector<int>& result) {
  auto pos = str.find(target);
  while (pos != std::string::npos) {
    result.emplace_back(pos);
    pos = str.find(target, pos + 1);
  }
}
struct gholem {
  int pos;
  char pos_name;
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, Q;
  string S;
  cin >> N >> Q;
  cin >> S;
  vector<char> t(Q, ' ');
  vector<char> d(Q, ' ');
  for (int ii = 0; ii < Q; ii++) {
    cin >> t[ii] >> d[ii];
  }
  vector<gholem> targets(N);
  for (int ii = 0; ii < N; ii++) {
    targets[ii].pos = ii;
    targets[ii].pos_name = S[ii];
  }
  vector<int> num(N, 1);
  vector<int> target_all;
  target_all.reserve(N);
  int ans = N;
  for (int ii = 0; ii < Q; ii++) {
    target_all.clear();
    find_all(S, t[ii], target_all);
    for (auto& target : target_all) {
      if (d[ii] == 'L') {
        if (target == 0) {
          num[target] = 0;
          continue;
        }
        num[target - 1] += num[target];
        num[target] = 0;
      } else {
        if (target == N - 1) {
          num[target] = 0;
          continue;
        }
        num[target + 1] += num[target];
        num[target] = 0;
      }
    }
  }
  ans = std::accumulate(num.begin(), num.end(), 0);
  cout << ans << endl;
}
