#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, tmp;
  string s;
  bool b;
  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++) {
      if (s[j] != t) continue;
      b = false;
      tmp = 0;
      if (a[j] > 0) {
        tmp = a[j];
        a[j] = 0;
        b = true;
      } else
        continue;
      if (d == 'L') {
        if (j == 0)
          ans += tmp;
        else
          a[j - 1] += tmp;
      } else {
        if (j == n - 1)
          ans += tmp;
        else
          a[j + 1] += tmp;
      }
    }
  }
  cout << n - ans << endl;
  return 0;
}
