#include <bits/stdc++.h>
using namespace std;
long long n, q;
string s;
vector<long long> v[26];
long long cnt[222222];
long long ans = 0;
signed main() {
  cin >> n >> q >> s;
  for (long long i = 0; i < n; ++i) v[s[i] - 'A'].push_back(i);
  fill(cnt, cnt + n, 1);
  for (long long i = 0; i < q; ++i) {
    char a, b;
    cin >> a >> b;
    if (b == 'L') {
      for (long long j = 0; j < v[a - 'A'].size(); ++j) {
        if (v[a - 'A'][j] == 0)
          ans += cnt[0];
        else
          cnt[v[a - 'A'][j] - 1] += cnt[v[a - 'A'][j]];
        cnt[v[a - 'A'][j]] = 0;
      }
    } else {
      for (long long j = 0; j < v[a - 'A'].size(); ++j) {
        if (v[a - 'A'][j] == n - 1)
          ans += cnt[n - 1];
        else
          cnt[v[a - 'A'][j] + 1] += cnt[v[a - 'A'][j]];
        cnt[v[a - 'A'][j]] = 0;
      }
    }
  }
  cout << n - ans << endl;
  return 0;
}
