#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  char t[Q];
  char d[Q];
  for (int i = 0; i < Q; ++i) cin >> t[i] >> d[i];
  map<char, vector<int>> m;
  for (int i = 0; i < N; ++i) m[S[i]].push_back(i);
  vector<int> s(N, 1);
  for (int i = 0; i < Q; ++i) {
    for (int j = 0; j < m[t[i]].size(); ++j) {
      if (s[m[t[i]][j]] > 0) {
        int x = s[m[t[i]][j]];
        s[m[t[i]][j]] -= x;
        if (d[i] == 'R' && m[t[i]][j] != N - 1) s[m[t[i]][j] + 1] += x;
        if (d[i] == 'L' && m[t[i]][j] != 0) s[m[t[i]][j] - 1] += x;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < N; ++i) res += s[i];
  cout << res << endl;
}
