#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main() {
  ll N, Q;
  string s;
  cin >> N >> Q >> s;
  char t[Q];
  char d[Q];
  for (ll i = 0; i < Q; i++) cin >> t[i] >> d[i];
  vector<vector<ll>> v;
  v.resize(26);
  for (ll i = 0; i < N; i++) {
    ll j = (ll)s[i] - 65;
    v[j].push_back(i);
  }
  ll cnt[N];
  fill(cnt, cnt + N, 1);
  for (ll i = 0; i < Q; i++) {
    ll pos = (ll)t[i] - 65;
    ll size = v[pos].size();
    if (d[i] == 'L') {
      for (ll j = 0; j < size; j++) {
        ll from = v[pos][j];
        if (from == 0)
          cnt[from] = 0;
        else {
          cnt[from - 1] += cnt[from];
          cnt[from] = 0;
        }
      }
    } else {
      for (ll j = size - 1; j >= 0; j--) {
        ll from = v[pos][j];
        if (from == N - 1)
          cnt[from] = 0;
        else {
          cnt[from + 1] += cnt[from];
          cnt[from] = 0;
        }
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < N; i++) ans += cnt[i];
  cout << ans << "\n";
  return 0;
}
