#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> counts(N, 1);
  multimap<char, int> tbl;
  for (long long i = 0; i < (N); ++i) {
    tbl.insert(make_pair(S[i], i));
  }
  for (long long i = 0; i < (Q); ++i) {
    char t, d;
    cin >> t >> d;
    auto range = tbl.equal_range(t);
    for (auto it = range.first; it != range.second; ++it) {
      int index = it->second;
      if (d == 'L') {
        if (index - 1 >= 0) {
          counts[index - 1] += counts[index];
        }
        counts[index] = 0;
      } else {
        if (index + 1 < N) {
          counts[index + 1] += counts[index];
        }
        counts[index] = 0;
      }
    }
  }
  int total = 0;
  for (long long i = 0; i < (N); ++i) {
    total += counts[i];
  }
  cout << total << endl;
  return 0;
}
