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