#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using namespace std;
template <class T>
void vin(vector<T>& v, int n) {
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<int> alp[30];
  for (int(i) = (0); (i) < (int)(s.size()); ++(i)) alp[s[i] - 'A'].push_back(i);
  vector<int> v(N + 2, 1);
  for (int(i) = (0); (i) < (int)(Q); ++(i)) {
    char t, d;
    cin >> t >> d;
    if (d == 'L')
      for (int& u : alp[t - 'A']) {
        int tmp = v[u + 1];
        v[u + 1] = 0;
        v[u] += tmp;
      }
    else
      for (int& u : alp[t - 'A']) {
        int tmp = v[u + 1];
        v[u + 1] = 0;
        v[u + 2] += tmp;
      }
  }
  int ans = 0;
  for (int i = 1; i <= N; ++i) ans += v[i];
  cout << ans << endl;
}
