#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<pair<char, char>> pi;
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    pi.push_back(make_pair(t, d));
  }
  int cnt = 0;
  int index = N - 1;
  for (int i = Q - 1; i >= 0; i--) {
    if (pi[i].second == 'R') {
      if (s[index] == pi[i].first) {
        index--;
        cnt++;
        if (index == 0) break;
      }
    }
  }
  int index2 = 0;
  for (int i = Q - 1; i >= 0; i--) {
    if (pi[i].second == 'L') {
      if (s[index2] == pi[i].first) {
        index2++;
        cnt++;
        if (index2 > index) break;
      }
    }
  }
  cout << N - cnt << endl;
  return 0;
}
