#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T>
inline void priv(vector<T> a) {
  for (int i = 0; i < a.size(); i++) {
    cerr << a[i] << ((i == a.size() - 1) ? "\n" : " ");
  }
}
inline void fastio() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int_fast64_t gcd(int_fast64_t a, int_fast64_t b) {
  int_fast64_t c = max(a, b);
  int_fast64_t d = min(a, b);
  return c == 0 || d == 0 ? c : gcd(c % d, d);
}
int_fast64_t lcm(int_fast64_t a, int_fast64_t b) {
  return a == 0 || b == 0 ? 0 : a * b / gcd(a, b);
}
int_fast64_t modfact(int_fast64_t a) {
  int_fast64_t b = 1;
  for (int i = 2; i <= a; i++) b = b * i % 1000000007LL;
  return b;
}
int_fast64_t modpow(int_fast64_t a, int_fast64_t n) {
  int_fast64_t b = 1;
  while (n > 0) {
    if (n & 1) b = b * a % 1000000007LL;
    a = a * a % 1000000007LL;
    n >>= 1;
  }
  return b;
}
int_fast64_t modcomb(int_fast64_t n, int_fast64_t k) {
  int_fast64_t b = 1;
  k = min(n - k, k);
  for (int i = n; i >= n - k + 1; i--) b = b * i % 1000000007LL;
  return b * modpow(modfact(k), 1000000007LL - 2) % 1000000007LL;
}
int N, Q;
char S[200000];
char ts[200000];
int ds[200000];
inline bool judge(int pos, bool left_judge) {
  if (pos < 0) return left_judge;
  if (pos >= N) return !left_judge;
  for (int i = 0; i < Q; i++) {
    if (S[pos] == ts[i]) {
      pos += ds[i];
      if (pos < 0) return left_judge;
      if (pos >= N) return !left_judge;
    }
  }
  return false;
}
inline int solve() {
  int l, r, m, res = 0;
  for (l = -1, r = N; r - l > 1;) {
    m = (r + l) / 2;
    if (judge(m, true))
      l = m;
    else
      r = m;
  }
  res -= l + 1;
  for (l = -1, r = N; r - l > 1;) {
    m = (r + l) / 2;
    if (judge(m, false))
      r = m;
    else
      l = m;
  }
  res += r;
  return res;
}
int main() {
  fastio();
  cin >> N >> Q;
  cin >> S;
  char d;
  for (int i = 0; i < Q; i++) {
    cin >> ts[i] >> d;
    ds[i] = d == 'R' ? 1 : -1;
  }
  cout << solve() << "\n";
  return 0;
}
