#include <bits/stdc++.h>
using namespace std;
struct square {
  int cnt = 1;
  square* L;
  square* R;
};
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<square*> v[0x5A + 1];
  square* prev = nullptr;
  for (int ii = 0; ii < N; ii++) {
    square* sq = new square();
    v[s[ii]].push_back(sq);
    if (prev != nullptr) {
      prev->R = sq;
      sq->L = prev;
    }
    prev = sq;
  }
  for (int ii = 0; ii < Q; ii++) {
    char t, d;
    cin >> t >> d;
    if (d == 'L') {
      for (int jj = 0; jj < v[t].size(); jj++) {
        if (v[t][jj]->L != nullptr) v[t][jj]->L->cnt += v[t][jj]->cnt;
        v[t][jj]->cnt = 0;
      }
    } else {
      for (int jj = v[t].size() - 1; jj >= 0; jj--) {
        if (v[t][jj]->R != nullptr) v[t][jj]->R->cnt += v[t][jj]->cnt;
        v[t][jj]->cnt = 0;
      }
    }
  }
  int total = 0;
  for (int ii = 0x41; ii < 0x5A; ii++) {
    for (auto square : v[ii]) {
      total += square->cnt;
    }
  }
  cout << total << endl;
  return 0;
}
