#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int n, q;
string s;
char t[200000];
char d[200000];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    scanf("%s %s", &t[i], &d[i]);
  }
  map<char, vector<int> > moji;
  int cnt[n];
  for (int i = 0; i < (int)(n); i++) {
    moji[s[i]].push_back(i);
    cnt[i] = 1;
  }
  int golems = n;
  for (int i = 0; i < (int)(q); i++) {
    vector<int> v = moji[t[i]];
    for (int j_ = 0; j_ < (int)(v.size()); j_++) {
      int j = v[j_];
      int c = cnt[j];
      cnt[j] = 0;
      if (d[i] == 'L') {
        if (j == 0) {
          golems -= c;
        } else {
          cnt[j - 1] += c;
        }
      } else {
        if (j == n - 1) {
          golems -= c;
        } else {
          cnt[j + 1] += c;
        }
      }
    }
  }
  printf("%d", golems);
  return 0;
}
