#include <bits/stdc++.h>
using namespace std;
class UF {
 private:
 public:
  UF *root;
  int value;
  UF(int n = 0) {
    root = this;
    value = n;
  }
  void showInfo(void) {
    cout << "rootNode:" << root << ",value:" << value << endl;
  }
};
void connectNode(UF *a, UF *b) {
  while (b->root != b) b = b->root;
  while (a->root != a) a = a->root;
  if (a > b) {
    a->root = b;
  }
  if (a < b) {
    b->root = a;
  }
  return;
}
bool hasSameRoot(UF *a, UF *b) {
  while (a->root != a) a = a->root;
  while (b->root != b) b = b->root;
  return a == b;
}
int main(int argc, char const *argv[]) {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<long long> a(n + 2);
  for (long long i = (long long)(0); i < (long long)(n + 2); ++i) a[i] = 1;
  a[0] = 0;
  a[n + 1] = 0;
  map<char, vector<int>> mp;
  char t[q], d[q];
  for (long long i = (long long)(1); i < (long long)(n + 1); ++i) {
    mp[s[i - 1]].push_back(i);
  }
  for (long long i = (long long)(0); i < (long long)(q); ++i) {
    cin >> t[i] >> d[i];
  }
  for (long long i = (long long)(0); i < (long long)(q); ++i) {
    auto _a = a;
    for (auto ind : mp[t[i]]) {
      if (d[i] == 'L') {
        a[ind - 1] += _a[ind];
        a[ind] = 0;
      } else {
        a[ind + 1] += _a[ind];
        a[ind] = 0;
      }
    }
  }
  cout << n - (a[0] + a[n + 1]) << endl;
  return 0;
}
