#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5, MAXM = 2e3 + 5, BOUND = 2e5, MOD = 1e9 + 7,
          INF = 0x3f3f3f3f;
const long long INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-3;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, q, cnt[MAXN];
char s[MAXN], t, d;
vector<int> v[33];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  cin >> (s + 1);
  for (int i = (1); i <= (n); ++i) {
    cnt[i] = 1;
    v[s[i] - 'A' + 1].push_back(i);
  }
  int ans = 0;
  for (int i = (1); i <= (q); ++i) {
    cin >> t >> d;
    for (int j = 0; j < v[t - 'A' + 1].size(); j++) {
      if (d == 'L') {
        cnt[v[t - 'A' + 1][j] - 1] += cnt[v[t - 'A' + 1][j]];
        cnt[v[t - 'A' + 1][j]] = 0;
      } else {
        cnt[v[t - 'A' + 1][j] + 1] += cnt[v[t - 'A' + 1][j]];
        cnt[v[t - 'A' + 1][j]] = 0;
      }
    }
  }
  for (int i = (1); i <= (n); ++i) ans += cnt[i];
  cout << ans << '\n';
  return 0;
}
