#include <bits/stdc++.h>
char query[(200 * 1000)][2];
bool die(int pos, int N, int Q, std::string text, bool isLeft) {
  for (int i = 0; i < Q; ++i) {
    if (text[pos] == query[i][0]) {
      if (query[i][1] == 'L') {
        --pos;
      } else {
        ++pos;
      }
      if (pos < 0) {
        return isLeft;
      }
      if (pos >= N) {
        return !isLeft;
      }
    }
  }
  return false;
}
int main() {
  int N, Q;
  std::string text;
  std::cin >> N >> Q >> text;
  for (int i = 0; i < Q; ++i) {
    std::cin >> query[i][0] >> query[i][1];
  }
  bool visited[(200 * 1000)];
  for (int i = 0; i < N; ++i) {
    visited[i] = false;
  }
  int Lmin = -1;
  int Lmax = N;
  int Rmin = -1;
  int Rmax = N;
  for (int i = 0; i < 20; ++i) {
    int Lpos = (Lmin + Lmax + 1) / 2;
    if (die(Lpos, N, Q, text, true)) {
      Lmin = Lpos;
    } else {
      Lmax = Lpos;
    }
    int Rpos = (Rmin + Rmax - 1) / 2;
    if (die(Rpos, N, Q, text, false)) {
      Rmax = Rpos;
    } else {
      Rmin = Rpos;
    }
  }
  if (Lmin > Rmax) {
    std::cout << 0 << std::endl;
  } else {
    std::cout << (Rmax - Lmin - 1) << std::endl;
  }
  return 0;
}
