#include <bits/stdc++.h>
using namespace std;
map<char, set<long long>> M;
string S;
struct Union_Find {
  vector<long long> par;
  Union_Find(long long N) : par(N) {
    for (long long i = (long long)(0); i < (long long)(N); i++) par[i] = i;
  }
  long long root(long long X) {
    if (par[X] == X || par[X] == -1 || par[X] == par.size()) return par[X];
    return par[X] = root(par[X]);
  }
  void insert(long long X, long long Y) {
    if (Y == -1) {
      par[X] = -1;
      M[S[X]].erase(X);
    } else if (Y == par.size()) {
      par[X] = par.size();
      M[S[X]].erase(X);
    } else {
      par[X] = Y;
      M[S[Y]].insert(Y);
      M[S[X]].erase(X);
    }
  }
  bool safe(long long X) {
    if (root(X) == -1 || root(X) == par.size()) return 0;
    return 1;
  }
};
signed main() {
  long long N, Q;
  cin >> N >> Q;
  cin >> S;
  for (long long i = (long long)(0); i < (long long)(N); i++) M[S[i]].insert(i);
  Union_Find tree(N);
  for (long long i = (long long)(0); i < (long long)(Q); i++) {
    char A, B;
    cin >> A >> B;
    long long X = 1;
    if (B == 'L') X = -1;
    set<long long> T(M[A]);
    for (auto p : T) {
      tree.insert(p, p + X);
    }
  }
  long long ans = 0;
  for (long long i = (long long)(0); i < (long long)(N); i++) {
    if (tree.safe(i)) ans++;
  }
  cout << ans << endl;
}
