#include <bits/stdc++.h>
using namespace std;
struct info {
  int pos;
  char dir;
};
int main() {
  const int M = 'Z' - 'A' + 1;
  vector<vector<info>> table(M);
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    table[t - 'A'].push_back({i, d});
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    int pos = i;
    int index = 0;
    bool death = false;
    for (int k = 0; k < table[S[pos] - 'A'].size(); k++) {
      info x = table[S[pos] - 'A'][k];
      int prev = pos;
      if (index > x.pos) {
        continue;
      }
      if (x.dir == 'R') {
        pos++;
      } else {
        pos--;
      }
      if (pos < 0 || pos >= N) {
        death = true;
        break;
      }
      index = x.pos;
      if (S[pos] != S[prev]) {
        k = -1;
      }
    }
    if (death) {
      count++;
    }
  }
  cout << N - count << endl;
  return 0;
}
