#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &a, T const &b) {
  a = min(a, b);
}
template <class T>
inline void amax(T &a, T const &b) {
  a = max(a, b);
}
inline long long square(long long x) { return x * x; }
inline long long gcd(long long a, long long b) {
  while (a) swap(a, b %= a);
  return b;
}
template <typename T>
inline T mod(T a, T b) {
  return ((a % b) + b) % b;
}
const long long MOD = 1000000007LL;
long long ADD(long long x, long long y) { return (x + y) % MOD; }
long long SUB(long long x, long long y) { return (x - y + MOD) % MOD; }
long long MUL(long long x, long long y) { return x * y % MOD; }
long long POW(long long x, long long e) {
  long long v = 1;
  for (; e; x = MUL(x, x), e >>= 1)
    if (e & 1) v = MUL(v, x);
  return v;
}
long long DIV(long long x, long long y) { return MUL(x, POW(y, MOD - 2)); }
char _buf[200000 + 3];
void read_cr() { fgets(_buf, 256, stdin); }
int solve(int N, int Q, string &s, vector<int> &t, vector<int> &q) {
  reverse((t).begin(), (t).end());
  reverse((q).begin(), (q).end());
  int rightmost = -1, leftmost = N, depth = -1;
  {
    int x = 0;
    for (int i = 0; i < Q; ++i) {
      if (x >= N - 1) break;
      bool rem = true;
      if (((0) <= (x) && (x) <= (N - 1)) && s[x] == t[i]) {
        rem = false;
      }
      if (((0) <= (x + 1) && (x + 1) <= (N - 1)) && s[x + 1] == t[i] &&
          q[i] == 'L') {
        rem = true;
        x++;
        rightmost = max(rightmost, x);
      }
      if (((0) <= (x - 1) && (x - 1) <= (N - 1)) && s[x - 1] == t[i] &&
          q[i] == 'R') {
        rem = true;
      }
      if (!rem) {
        --x;
        --i;
        if (x < -1) break;
      }
    }
  }
  {
    int x = N;
    for (int i = 0; i < Q; ++i) {
      if (x <= 0) break;
      bool rem = true;
      if (((0) <= (x) && (x) <= (N - 1)) && s[x] == t[i]) {
        rem = false;
      }
      if (((0) <= (x + 1) && (x + 1) <= (N - 1)) && s[x + 1] == t[i] &&
          q[i] == 'L') {
        rem = true;
      }
      if (((0) <= (x - 1) && (x - 1) <= (N - 1)) && s[x - 1] == t[i] &&
          q[i] == 'R') {
        rem = true;
        x--;
        leftmost = min(leftmost, x);
      }
      if (!rem) {
        ++x;
        --i;
        if (x > N) break;
      }
    }
  }
  return max(0, leftmost - rightmost - 1);
}
int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);
  read_cr();
  fgets(_buf, N + 3, stdin);
  string s(_buf, _buf + N);
  vector<int> t(Q), d(Q);
  for (int i = 0; i < (Q); ++i) {
    fgets(_buf, 10, stdin);
    t[i] = _buf[0];
    d[i] = _buf[2];
  }
  printf("%d\n", solve(N, Q, s, t, d));
  return 0;
}
