#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, q, mass[200100], ans = 0;
  char t, d;
  string s;
  cin >> n >> q >> s;
  for (int i = 0; i < s.size(); i++) {
    mass[i] = 1;
  }
  for (int i = 0; i < q; i++) {
    cin >> t >> d;
    for (int j = 0; j < n; j++) {
      if (t == s[j]) {
        if (j == 0 && d == 'L' || j == n - 1 && d == 'R') {
          mass[j] = 0;
        } else if (d == 'L') {
          mass[j - 1] += mass[j];
          mass[j] = 0;
        } else {
          mass[j + 1] += mass[j];
          mass[j] = 0;
        }
      }
    }
  }
  for (int i = 0; i < s.size(); i++) {
    ans += mass[i];
  }
  cout << ans << endl;
  return 0;
}
