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