#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, Q;
  cin >> N >> Q;
  pair<char, int> P[N + 2];
  string s;
  cin >> s;
  P[0] = make_pair('a', 0);
  P[N + 1] = make_pair('z', 0);
  for (int i = 1; i < N + 2; i++) {
    P[i] = make_pair(s[i - 1], 1);
  }
  char t, d;
  for (int i = 1; i <= Q; i++) {
    cin >> t >> d;
    for (int j = 1; j < N + 2; j++) {
      if (P[j].first == t) {
        if (d == 'R') {
          P[j + 1].second = P[j + 1].second + P[j].second;
          P[j].second = 0;
        } else {
          P[j - 1].second = P[j - 1].second + P[j].second;
          P[j].second = 0;
        }
      }
    }
  }
  int ans;
  ans = 0;
  for (int i = 1; i <= N; i++) {
    ans = ans + P[i].second;
  }
  cout << ans << endl;
  return 0;
}
