#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 100000000;
int in() {
  int a;
  cin >> a;
  return a;
}
void forin(int* x, int y) {
  for (int i = 0; i < y; i++) {
    cin >> x[i];
  }
}
int intpow(int x, int y) {
  double a = x, b = y;
  return pow(a, b);
}
int intfabs(int x) {
  double a = x;
  return fabs(a);
}
int fact(int x) {
  if (x == 1) return 1;
  return x * fact(x - 1);
}
int fib(int x) {
  if (x <= 2) return x;
  int a[x];
  a[0] = 1;
  a[1] = 2;
  for (int i = 2; i < x; i++) {
    a[i] = a[i - 1] + a[i - 2];
  }
  return a[x - 1];
}
int main() {
  int n = in(), q = in(), g[n + 2];
  char s[n], t, d;
  g[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    g[i] = 1;
  }
  g[n + 1] = 0;
  for (int i = 0; i < q; i++) {
    cin >> t >> d;
    if (d == 'L') {
      for (int i2 = 1; i <= n; i++) {
        if (s[i2] == t) {
          g[i2 - 1] += g[i2];
          g[i2] = 0;
        }
      }
    } else {
      for (int i2 = n; i > 0; i--) {
        if (s[i2] == t) {
          g[i2 + 1] += g[i2];
          g[i2] = 0;
        }
      }
    }
  }
  cout << n - g[0] - g[n + 1] << endl;
}
