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