#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using std::cin;
using std::cout;
using std::lower_bound;
using std::string;
using std::upper_bound;
using std::vector;
using vi = vector<long long>;
using vii = vector<vi>;
using pii = std::pair<long long, long long>;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1e7;
constexpr long long INF = (1ll << 60);
template <class T>
class prique : public std::priority_queue<T, std::vector<T>, std::greater<T>> {
};
struct Binary_indexed_tree {
  int N;
  vi bit;
  Binary_indexed_tree(int n) : N(n) { bit.resize(N + 1, 0); }
  void add(int x, int a) {
    for (x; x <= N; x += (x & -x)) bit[x] += a;
  }
  long long sum(int x) {
    long long ret = 0;
    for (x; x > 0; x -= (x & -x)) ret += bit[x];
    return ret;
  }
  long long lower_bound(long long X) {
    if (sum(N) < X) return -1;
    long long ret = 0, memo = 1, sum = 0;
    while (memo * 2 <= N) memo *= 2;
    while (memo > 0) {
      if (memo + ret <= N && sum + bit[memo + ret] < X) {
        sum += bit[memo + ret];
        ret += memo;
      }
      memo /= 2;
    }
    return ret + 1;
  }
};
struct Union_Find {
  long long N;
  vi par;
  vi siz;
  Union_Find(int n) : N(n) {
    par.resize(N);
    siz.resize(N, 1);
    for (long long i = (long long)(0); i < (long long)(N); i++) par[i] = i;
  }
  long long root(long long X) {
    if (par[X] == X) return X;
    return par[X] = root(par[X]);
  }
  bool same(long long X, long long Y) { return root(X) == root(Y); }
  void unite(long long X, long long Y) {
    X = root(X);
    Y = root(Y);
    if (X == Y) return;
    par[X] = Y;
    siz[Y] += siz[X];
    siz[X] = 0;
  }
  long long size(long long X) { return siz[root(X)]; }
};
long long modpow(long long X, long long Y, long long mod) {
  long long sum = X, cnt = 1;
  vi A;
  while (cnt <= Y) {
    A.emplace_back(sum);
    sum *= sum;
    sum %= mod;
    cnt *= 2;
  }
  int M = A.size();
  long long ret = 1;
  for (long long i = (long long)(1); i <= (long long)(M); i++) {
    if (Y >= (1ll << M - i)) {
      Y -= (1ll << M - i);
      ret *= A[M - i];
      ret %= mod;
    }
  }
  return ret;
}
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(long long n, long long r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fac[n] * finv[r] % MOD * finv[n - r] % MOD;
}
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  long long N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<char> T(Q), D(Q);
  for (long long i = (long long)(0); i < (long long)(Q); i++) {
    cin >> T[i] >> D[i];
  }
  long long left = 0, right = N;
  long long ans = N;
  while (left + 1 < right) {
    long long mid = (left + right) / 2;
    if (mid == 0)
      left = mid;
    else {
      long long X = mid - 1;
      bool flag = 1;
      for (long long i = (long long)(0); i < (long long)(Q); i++) {
        if (S[X] == T[i]) {
          if (D[i] == 'L')
            X--;
          else
            X++;
        }
        if (X == -1) {
          flag = 0;
          break;
        }
        if (X == N) break;
      }
      if (flag)
        right = mid;
      else
        left = mid;
    }
  }
  long long memo = left;
  long long x = right - 1;
  bool f = 1;
  for (long long i = (long long)(0); i < (long long)(Q); i++) {
    if (S[x] == T[i]) {
      if (D[i] == 'L')
        x--;
      else
        x++;
    }
    if (x == -1) {
      f = 0;
      break;
    }
    if (x == N) break;
  }
  if (!f) memo = right;
  ans -= memo;
  left = 0, right = N;
  while (left + 1 < right) {
    long long mid = (left + right) / 2;
    if (mid == 0)
      left = mid;
    else {
      long long X = N - mid;
      bool flag = 1;
      for (long long i = (long long)(0); i < (long long)(Q); i++) {
        if (S[X] == T[i]) {
          if (D[i] == 'L')
            X--;
          else
            X++;
        }
        if (X == N) {
          flag = 0;
          break;
        }
        if (X == -1) break;
      }
      if (flag)
        right = mid;
      else
        left = mid;
    }
  }
  memo = N - right, f = 1;
  for (long long i = (long long)(0); i < (long long)(Q); i++) {
    if (S[x] == T[i]) {
      if (D[i] == 'L')
        x--;
      else
        x++;
    }
    if (x == N) {
      f = 0;
      break;
    }
    if (x == -1) break;
  }
  if (!f) memo = right;
  ans -= memo;
  cout << ans << "\n";
}
