#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, a = 0, b = 0;
  cin >> n >> q;
  string str;
  cin >> str;
  vector<int> num(n + 1);
  for (int i = 0; i < n; i++) {
    num[i] = 1;
  }
  cout << endl;
  char name, dir;
  for (int i = 0; i < q; i++) {
    cin >> name >> dir;
    for (int j = 0; j < n; j++) {
      if ((j == 0 && str.at(j) == name && dir == 'L') ||
          (j == n - 1 && str.at(j) == name && dir == 'R'))
        num[j] = 0;
      else if (str.at(j) == name && dir == 'L') {
        num[j - 1] += num[j];
        num[j] = 0;
      } else if (str.at(j) == name && dir == 'R') {
        num[j + 1] += num[j];
        num[j] = 0;
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += num[i];
  }
  cout << sum << endl;
}
