#include <bits/stdc++.h>
using namespace std;
int main() {
  int NumMasu, NumJumon;
  int countR = 0, countB = 0;
  string input;
  char* masu;
  char* jumon;
  int* golem;
  int sum = 0;
  cin >> NumMasu >> NumJumon;
  masu = new char[NumJumon];
  jumon = new char[NumJumon];
  golem = new int[NumMasu];
  for (size_t i = 0; i < NumMasu; i++) {
    golem[i] = 1;
  }
  cin >> input;
  for (int i = 0; i < NumJumon; i++) {
    cin >> masu[i] >> jumon[i];
    for (int j = 0; j < NumMasu; j++) {
      if (input[j] == masu[i]) {
        if (jumon[i] == 'R') {
          if (j != NumMasu - 1) {
            golem[j + 1] += golem[j];
          }
          golem[j] = 0;
        } else {
          if (j != 0) {
            golem[j - 1] += golem[j];
          }
          golem[j] = 0;
        }
      }
    }
  }
  for (int i = 0; i < NumMasu; i++) {
    sum += golem[i];
  }
  cout << sum << endl;
  delete[] masu;
  delete[] jumon;
  delete[] golem;
  return 0;
}
