#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, Q;
string s;
void input() { cin >> N >> Q >> s; }
ll solve() {
  vector<ll> spos[0xff];
  for (ll i = 0; i < N; i++) {
    spos[ll(s[i])].push_back(i);
  }
  ll dels = 0;
  vector<ll> golems(N, 1);
  for (ll n = 0; n < Q; n++) {
    char t, d;
    cin >> t >> d;
    vector<ll> deltas(N, 0);
    for (ll pos : spos[ll(t)]) {
      if (d == 'L') {
        if (pos == 0) {
          dels += golems[0];
        } else {
          deltas[pos - 1] += golems[pos];
        }
      } else {
        if (pos == N - 1) {
          dels += golems[N - 1];
        } else {
          deltas[pos + 1] += golems[pos];
        }
      }
      golems[pos] = 0;
    }
    for (ll i = 0; i < N; i++) {
      golems[i] += deltas[i];
    }
  }
  return N - dels;
}
int main() {
  input();
  cout << solve() << endl;
  return 0;
}
