#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int i, j, N, Q;
  int deleted = 0;
  string s;
  char t, d;
  cin >> N >> Q;
  cin >> s;
  vector<int> data(N, 1);
  for (i = 0; i < Q; i++) {
    cin >> t >> d;
    for (j = 0; j < N; j++) {
      if (s[j] == t) {
        if (j == 0 && d == 'L') {
          deleted += data[0];
          data[0] = 0;
        } else if (j == N - 1 && d == 'R') {
          deleted += data[N - 1];
          data[N - 1] = 0;
        } else {
          if (d == 'L') {
            data[j - 1] += data[j];
            data[j] = 0;
          } else {
            data[j + 1] += data[j];
            data[j] = 0;
          }
        }
      }
    }
  }
  cout << N - deleted << endl;
  return 0;
}
