#include <bits/stdc++.h>
std::vector<char> t, d;
std::string s;
int N, Q;
int end(int);
int main() {
  scanf("%d%d", &N, &Q);
  std::cin >> s;
  t.resize(Q);
  d.resize(Q);
  for (int i{}; i < Q; i++) scanf(" %c %c", &t[i], &d[i]);
  int left{}, right{N};
  while (left + 1 < right) {
    int mid{(left + right) / 2};
    if (end(mid) == -1)
      left = mid;
    else
      right = mid;
  }
  int sum{left + 1};
  left = -1;
  right = N;
  while (left + 1 < right) {
    int mid{(left + right) / 2};
    if (end(mid) == N)
      right = mid;
    else
      left = mid;
  }
  sum += N - right;
  printf("%d\n", N - sum);
  return 0;
}
int end(int pos) {
  for (int i{}; i < Q; i++) {
    if (pos < 0 || pos >= N) return pos;
    if (t[i] != s[pos]) continue;
    if (d[i] == 'R')
      pos++;
    else
      pos--;
  }
  return pos;
}
