#include <bits/stdc++.h>
using namespace std;
struct Box {
  int number;
  int golem;
  char str;
};
struct Spell {
  char str;
  char direction;
};
int main() {
  int N, Q;
  cin >> N >> Q;
  Box box[N + 2];
  Spell spell[Q];
  int counter = 0;
  for (int i = 1; i <= N; i++) {
    cin >> box[i].str;
    box[i].number = i;
    box[i].golem = 1;
  }
  for (int i = 0; i < Q; i++) {
    cin >> spell[i].str >> spell[i].direction;
  }
  for (int i = 0; i < Q; i++) {
    for (int j = 1; j <= N; j++) {
      if (spell[i].str == box[j].str) {
        if (spell[i].direction == 'R')
          box[j + 1].golem += box[j].golem;
        else
          box[j - 1].golem += box[j].golem;
        box[j].golem = 0;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    counter += box[i].golem;
  }
  cout << counter << endl;
}
