#include <bits/stdc++.h>
using namespace std;
int n, q;
string a[200005], b[200005], c, d, st;
bitset<200005> cur, f[26];
int main() {
  cin >> n >> q >> st;
  cur[0] = cur[n + 1] = true;
  for (int i = 0; i < n; ++i) {
    f[st[i] - 'A'][i + 1] = true;
  }
  for (int i = 0; i < q; ++i) {
    cin >> a[i] >> b[i];
  }
  for (int i = q - 1; i >= 0; --i) {
    c = a[i];
    d = b[i];
    if (d[0] == 'L') {
      cur = ((cur << 1) & f[c[0] - 'A']) | (cur & ~f[c[0] - 'A']);
    } else {
      cur = ((cur >> 1) & f[c[0] - 'A']) | (cur & ~f[c[0] - 'A']);
    }
  }
  cur[0] = cur[n + 1] = false;
  cout << n - cur.count() << endl;
  return 0;
}
