#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long EPS = 1e-9;
const long long N = 5 * 1e6;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<long long> a[26];
  for (long long i = 0; i < n; i++) a[s[i] - 'A'].push_back(i);
  long long ans[n];
  for (long long i = 0; i < n; i++) ans[i] = 1;
  while (q--) {
    char t;
    cin >> t;
    char d;
    cin >> d;
    for (auto x : a[t - 'A']) {
      if (d == 'L') {
        if (x == 0) {
          ans[x] = 0;
        } else
          ans[x - 1] += ans[x], ans[x] = 0;
      } else {
        if (x == n - 1) {
          ans[x] = 0;
        } else
          ans[x + 1] += ans[x], ans[x] = 0;
      }
    }
  }
  long long an = 0;
  for (long long i = 0; i < n; i++) an += ans[i];
  cout << an;
}
