#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j;
  long long N, Q;
  char c;
  char t, d;
  long long cnt = 0;
  pair<char, long long> ch[10000];
  string S;
  cin >> N >> Q;
  for (i = 1; i <= N; i++) {
    cin >> c;
    ch[i] = make_pair(c, 1);
  }
  for (j = 0; j < Q; j++) {
    cin >> t >> d;
    for (i = 1; i <= N; i++) {
      if (ch[i].first == t) {
        if (d == 'R') {
          ch[i + 1] =
              make_pair(ch[i + 1].first, ch[i + 1].second + ch[i].second);
          ch[i] = make_pair(ch[i].first, 0);
        }
        if (d == 'L') {
          ch[i - 1] =
              make_pair(ch[i - 1].first, ch[i - 1].second + ch[i].second);
          ch[i] = make_pair(ch[i].first, 0);
        }
      }
    }
  }
  for (i = 1; i <= N; i++) cnt += ch[i].second;
  cout << cnt << endl;
}
