#include <bits/stdc++.h>
std::mt19937 rng(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  int n, q;
  std::cin >> n >> q;
  std::vector<int> mn(26, 0), mx(26, 0), on(26, 0);
  std::string str;
  std::cin >> str;
  std::vector<char> c(n), d(n);
  for (int i = 0; i < q; i++) {
    std::cin >> c[i] >> d[i];
  }
  auto simulate = [&](int pos) {
    for (int i = 0; i < q && pos >= 0 && pos < n; i++) {
      if (str[pos] == c[i]) {
        pos += (d[i] == 'L' ? -1 : 1);
      }
    }
    return pos;
  };
  int l = 0, r = n;
  while (l != r) {
    int mid = (l + r + 1) / 2;
    if (simulate(mid - 1) == -1) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  int left = l - 1;
  l = 0, r = n;
  while (l != r) {
    int mid = (l + r) / 2;
    if (simulate(mid) == n) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  std::cout << std::max(0, l - left - 1) << '\n';
}
