#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, q;
  string s;
  cin >> n >> q >> s;
  std::vector<int> num(n, 1);
  char t, d;
  map<char, vector<int>> dict;
  vector<int> v1(1);
  for (int i = 0; i < n; ++i) {
    auto ite = dict.find(s[i]);
    if (ite == dict.end()) {
      v1[0] = i;
      dict.insert(make_pair(s[i], v1));
    } else {
      ite->second.push_back(i);
    }
  }
  for (int i = 0; i < q; ++i) {
    cin >> t >> d;
    const auto ite = dict.find(t);
    if (ite == dict.end()) {
      continue;
    }
    for (const auto &k : ite->second) {
      if (d == 'L') {
        if (k > 0) {
          num[k - 1] += num[k];
        }
        num[k] = 0;
      } else {
        if (k < n - 1) {
          num[k + 1] += num[k];
        }
        num[k] = 0;
      }
    }
  }
  int ans = accumulate(num.begin(), num.end(), 0);
  cout << ans;
  return 0;
}
