#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
long long gcd(long long x, long long y) { return (y == 0) ? x : gcd(y, x % y); }
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
int main() {
  long long n, q, ans = 0;
  string s;
  char t, d;
  cin >> n >> q >> s;
  long long a[n];
  for (int i = 0; i < n; i++) a[i] = 1;
  for (int i = 0; i < q; i++) {
    cin >> t >> d;
    for (int j = 0; j < n; j++) {
      bool b = false;
      long long tmp = 0;
      if (s[j] == t) {
        if (d == 'L') {
          if (a[j] > 0) {
            tmp = a[j];
            a[j] = 0;
            b = true;
          }
          if (j == 0 && b)
            ans += tmp;
          else {
            if (b) a[j - 1] += tmp;
          }
        } else {
          if (a[j] > 0) {
            tmp = a[j];
            a[j] = 0;
            b = true;
          }
          if (j == n - 1 && b)
            ans += tmp;
          else {
            if (b) a[j + 1] += tmp;
          }
        }
      }
    }
  }
  cout << n - ans << endl;
  return 0;
}
