#include <bits/stdc++.h>
using namespace std;
struct M {
  char t, d;
};
int main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<M> m(q);
  for (auto &&e : m) {
    cin >> e.t >> e.d;
  }
  long long lCount = 0, rCount = 0;
  for (long long i = q - 1; i >= 0; --i) {
    if (m[i].d == 'L') {
      if (s[lCount] == m[i].t) {
        ++lCount;
      }
    } else {
      if (s[n - 1 - rCount] == m[i].t) {
        ++rCount;
      }
    }
  }
  cout << n - (lCount + rCount) << endl;
}
