#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<int> mp(N, 1);
  vector<vector<int>> namedPos(26);
  for (int i = 0; i < N; i++) {
    int size = namedPos[s[i] - 'A'].size() - 1;
    if (size >= 0 and namedPos[s[i] - 'A'][size] == i - 1 and
        namedPos[s[i] - 'A'][size - 1] == i - 2) {
      namedPos[s[i] - 'A'][size] = i;
    } else {
      namedPos[s[i] - 'A'].push_back(i);
    }
  }
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    for (int n : namedPos[t - 'A']) {
      int delta = (d == 'L' ? -1 : 1);
      if (n + delta < 0 || n + delta >= N) {
        mp[n] = 0;
      } else {
        mp[n + delta] += mp[n];
        mp[n] = 0;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += mp[i];
  }
  cout << ans << endl;
  return 0;
}
