#include <bits/stdc++.h>
using namespace std;
struct info {
  int pos, index;
};
int main() {
  const int M = 'Z' - 'A' + 1;
  vector<vector<pair<int, int>>> table(M);
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    table[t - 'A'].push_back({d, i});
  }
  int count = 0;
  vector<info> list;
  for (int i = 0; i < N; i++) {
    if (table[S[i] - 'A'].empty()) {
      continue;
    }
    auto x = table[S[i] - 'A'][0];
    int pos = i;
    if (x.first == 'R') {
      pos++;
    } else {
      pos--;
    }
    if (pos < 0 || pos >= N) {
      count++;
    } else {
      list.push_back({pos, x.second});
    }
  }
  while (!list.empty()) {
    vector<info> nextList;
    for (int i = 0; i < list.size(); i++) {
      for (int k = 0; k < table[S[list[i].pos] - 'A'].size(); k++) {
        auto x = table[S[list[i].pos] - 'A'][k];
        if (x.second <= list[i].index) {
          continue;
        }
        int pos = list[i].pos;
        if (x.first == 'R') {
          pos++;
        } else {
          pos--;
        }
        if (pos < 0 || pos >= N) {
          count++;
        } else {
          nextList.push_back({pos, x.second});
        }
      }
    }
    list = nextList;
  }
  cout << N - count << endl;
  return 0;
}
