#include <bits/stdc++.h>
static const int MOD = 1000000007;
static const int INF = ((1 << 30) - 1);
static const int64_t LINF = ((1LL << 62) - 1);
struct Comb {
  std::vector<std::vector<int64_t> > a;
  Comb(int n) {
    a.resize(n + 1);
    for (int i = (0); i <= ((int)((n + 1) - 1)); i++) {
      a[i].resize(i + 1, 1);
      for (int j = (1); j <= ((int)(i - 1)); j++)
        a[i][j] = a[i - 1][j] + a[i - 1][j];
    }
  }
  int64_t ncr(int n, int r) {
    assert(n >= 0);
    assert(n <= (int)a.size());
    assert(r >= 0);
    assert(r <= n);
    return a[n][r];
  }
};
int ri() {
  int c, s = 0, r = 0;
  for (;;) {
    (c) = getchar();
    if (c == '-') {
      s = 1;
      break;
    }
    if (c >= '0' && c <= '9') {
      r = c - '0';
      break;
    }
  }
  for (;;) {
    (c) = getchar();
    if (c < '0' || c > '9') break;
    r *= 10;
    r += c - '0';
  }
  if (s) r = -r;
  return r;
}
int64_t rs64() {
  int64_t r;
  int c, s;
  for (;;) {
    (c) = getchar();
    if (c == '-') {
      s = 1;
      break;
    }
    if (c >= '0' && c <= '9') {
      r = c - '0';
      break;
    }
  }
  for (;;) {
    (c) = getchar();
    if (c < '0' || c > '9') break;
    r *= 10;
    r += c - '0';
  }
  if (s) r = -r;
  return r;
}
int int_less(const void* a, const void* b) {
  return (*(const int*)a - *(const int*)b);
}
int int_greater(const void* a, const void* b) {
  return (*(const int*)b - *(const int*)a);
}
std::string operator*(const std::string& s, int n) {
  std::string res;
  for (int i = (0); i <= ((int)((n)-1)); i++) res += s;
  return res;
}
template <class T>
std::ostream& operator<<(std::ostream& os, std::vector<T> a) {
  for (auto i : a) os << i << " ";
  return os;
}
template <class T>
std::ostream& operator<<(std::ostream& os, std::set<T> a) {
  for (auto i : a) os << i << " ";
  return os;
}
template <class A, class B>
std::ostream& operator<<(std::ostream& os, std::pair<A, B> a) {
  os << a.first << "," << a.second;
  return os;
}
int main() {
  int n = ri();
  int q = ri();
  std::string s;
  std::cin >> s;
  char a[q], b[q];
  for (int i = (0); i <= ((int)((q)-1)); i++) {
    std::string tmp;
    std::cin >> tmp;
    a[i] = tmp[0];
    std::cin >> tmp;
    b[i] = tmp[0];
  }
  int left = -1;
  int right = n;
  for (int i = ((q)-1); i >= ((int)(0)); i--) {
    if (b[i] == 'L') {
      if (left != n - 1) {
        if (a[i] == s[left + 1]) left++;
      }
    } else {
      if (right != 0) {
        if (a[i] == s[right - 1]) right--;
      }
    }
    if (right - left <= 1) break;
  }
  std::cout << (right - left - 1) << std::endl;
  return 0;
}
