#include <bits/stdc++.h>
long long int N, Q;
std::string s;
std::vector<char> t, d;
bool check1(long long int p) {
  for (long long int i = 0; i < Q; ++i) {
    if (s[p] == t[i]) {
      if (d[i] == 'L')
        --p;
      else
        ++p;
    }
    if (p < 0) return true;
    if (p >= N) return false;
  }
  return false;
}
bool check2(long long int p) {
  for (long long int i = 0; i < Q; ++i) {
    if (s[p] == t[i]) {
      if (d[i] == 'L')
        --p;
      else
        ++p;
    }
    if (p < 0) return false;
    if (p >= N) return true;
  }
  return false;
}
int main() {
  std::cin >> N >> Q >> s;
  t.resize(Q);
  d.resize(Q);
  for (long long int i = 0; i < Q; ++i) std::cin >> t[i] >> d[i];
  long long int left1 = 0, right1 = N + 1;
  while (right1 - left1 > 1) {
    long long int mid = (left1 + right1) / 2;
    if (check1(mid))
      left1 = mid;
    else
      right1 = mid;
  }
  long long int left2 = -1, right2 = N;
  while (right2 - left2 > 1) {
    long long int mid = (left2 + right2) / 2;
    if (check2(mid))
      right2 = mid;
    else
      left2 = mid;
  }
  std::cout << left2 - right1 + 1 << std::endl;
}
