#include <bits/stdc++.h>
int N, Q;
std::string s;
char t[222222], d[222222];
int compute(int x) {
  for (int i = 0; i < Q; i++)
    if (s[x] == t[i]) {
      x += d[i] == 'L' ? -1 : 1;
      if (x < 0) return -1;
      if (x >= N) return 1;
    }
  return 0;
}
int main(int argc, char** argv) {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);
  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);
  std::cin >> N >> Q >> s;
  for (int i = 0; i < Q; i++) std::cin >> t[i] >> d[i];
  int l = -1, r = N - 1;
  while (r - l > 1) {
    int m = (l + r) / 2;
    int x = compute(m);
    (x == -1 ? l : r) = m;
  }
  int m = r;
  l = -1, r = N;
  while (r - l > 1) {
    int m = (l + r) / 2;
    int x = compute(m);
    (x == 1 ? r : l) = m;
  }
  int p = r;
  std::cout << p - m << std::endl;
  return 0;
}
