#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  map<char, vector<long long>> m;
  for (long long i = 0; i < n; ++i) {
    m[s[i]].emplace_back(i);
  }
  vector<long long> g(n, 1);
  for (long long i = 0; i < q; ++i) {
    char t, d;
    cin >> t >> d;
    if (d == 'L') {
      auto it = m[t].cbegin();
      auto itEnd = m[t].cend();
      for (; it != itEnd; ++it) {
        if (*it != 0) g[(*it) - 1] += g[*it];
        g[*it] = 0;
      }
    } else {
      auto it = m[t].crbegin();
      auto itEnd = m[t].crend();
      for (; it != itEnd; ++it) {
        if ((*it) != n - 1) g[*it + 1] += g[*it];
        g[*it] = 0;
      }
    }
  }
  long long count = 0;
  for (auto&& e : g) {
    count += e;
  }
  cout << count << endl;
}
