#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
int main() {
  ll N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<ll> Alpha(N);
  vector<vector<ll>> adj(26);
  for (ll i = 0; i < N; i++) {
    Alpha[i] = S[i] - 'A';
    adj[Alpha[i]].push_back(i);
  }
  vector<ll> Golem(N, 1), Query(Q), Direct(Q);
  char t_i, d_i;
  ll t;
  for (ll i = 0; i < Q; i++) {
    cin >> t_i >> d_i;
    t = t_i - 'A';
    Query[i] = t;
    Direct[i] = (d_i == 'L' ? -1 : +1);
  }
  ll que, dir, now_G, res = N;
  for (ll i = 0; i < Q; i++) {
    que = Query[i], dir = Direct[i];
    if (adj[que].empty())
      continue;
    else {
      vector<ll> a = adj[que];
      for (ll j = 0; j < a.size(); j++) {
        now_G = Golem[a[j]];
        if (now_G >= 1) {
          Golem[a[j]] = 0;
          if (0 <= a[j] + dir && a[j] + dir <= N - 1) {
            Golem[a[j] + dir] += now_G;
          }
        }
      }
    }
  }
  cout << accumulate(Golem.begin(), Golem.end(), 0LL) << "\n";
  return 0;
}
