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