#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  map<char, vector<int> > m;
  int golemArray[N];
  for (int i = 0; i < N; i++) {
    golemArray[i] = 1;
    if (m.find(s[i]) == m.end()) {
      vector<int> v;
      v.push_back(i);
      m[s[i]] = v;
    } else {
      vector<int> v = m[s[i]];
      v.push_back(i);
      m[s[i]] = v;
    }
  }
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    if (m.find(t) == m.end()) {
      continue;
    }
    vector<int> v = m[t];
    for (int index : v) {
      if (d == 'L') {
        if (index != 0) {
          golemArray[index - 1] += golemArray[index];
        }
        golemArray[index] = 0;
      } else {
        if (index != N - 1) {
          golemArray[index + 1] += golemArray[index];
        }
        golemArray[index] = 0;
      }
    }
  }
  int ret = 0;
  for (int i = 0; i < N; i++) {
    ret += golemArray[i];
  }
  cout << ret << endl;
  return 0;
}
