#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int>* pos = new vector<int>[26]();
  int* count = new int[n];
  for (int i = 0; i < n; i++) {
    count[i] = 1;
    char x = s[i] - 'A';
    pos[x].push_back(i);
  }
  while (q--) {
    char t, d;
    cin >> t >> d;
    int change;
    if (d == 'L')
      change = -1;
    else
      change = 1;
    vector<int> current = pos[t - 'A'];
    for (int i = 0; i < current.size(); i++) {
      int p = current[i];
      int temp = count[p];
      count[p] = 0;
      if (p + change >= 0 && p + change < n) count[p + change] += temp;
    }
  }
  int total = 0;
  for (int i = 0; i < n; i++) {
    total += count[i];
  }
  cout << total << "\n";
  return 0;
}
