#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  cin >> m >> n;
  vector<int> gol(m, 1);
  string s;
  cin >> s;
  char ch, lr;
  for (int i = 0; i < n; i++) {
    cin >> ch >> lr;
    size_t found = s.find(ch);
    while (found != string::npos) {
      int tmp = static_cast<int>(found);
      if (lr == 'L' and tmp > 0) {
        gol[tmp - 1] += gol[tmp];
      } else if (lr == 'R' and tmp < m - 1) {
        gol[tmp + 1] += gol[tmp];
      }
      gol[tmp] = 0;
      found = s.find(ch, found + 1);
    }
  }
  cout << accumulate(gol.begin(), gol.end(), 0) << endl;
}
