#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  long int mas[n];
  for (int j = 0; j < n; j++) mas[j] = 1;
  char t[q], d[q];
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  for (int i = 0; i < q; i++) {
    if (d[i] == 'L') {
      for (int j = 0; j < n; j++) {
        if (s[j] == t[i] && j != 0) {
          mas[j - 1] += mas[j];
          mas[j] = 0;
        } else if (s[j] == t[i])
          mas[0] = 0;
      }
    } else {
      for (int j = n - 1; j >= 0; j--) {
        if (s[j] == t[i] && j != n - 1) {
          mas[j + 1] += mas[j];
          mas[j] = 0;
        } else if (s[j] == t[i])
          mas[n - 1] = 0;
      }
    }
  }
  long int sum = 0;
  for (int i = 0; i < n; i++) sum += mas[i];
  cout << sum << endl;
}
