#include <bits/stdc++.h>
using namespace std;
static const long long INF = 1e18;
static const long long MAX = 1e5 + 7;
static const long long MOD = 1e9 + 7;
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
long long N, Q;
string s;
char t[MAX], d[MAX];
long long L(long long now) {
  long long i;
  for (i = 0; i < Q; i++) {
    if (s[now] == t[i]) {
      if (d[i] == 'L') now--;
      if (d[i] == 'R') now++;
      if (now < 0) return 1;
    }
  }
  return 0;
}
long long R(long long now) {
  long long i;
  for (i = 0; i < Q; i++) {
    if (s[now] == t[i]) {
      if (d[i] == 'L') now--;
      if (d[i] == 'R') now++;
      if (now >= N) return 1;
    }
  }
  return 0;
}
int main(void) {
  cin >> N >> Q;
  cin >> s;
  long long i, j;
  for (i = 0; i < Q; i++) cin >> t[i] >> d[i];
  long long l = 0, r = N;
  while (l + 1 < r) {
    long long mid = (l + r) / 2;
    if (L(mid))
      l = mid;
    else
      r = mid;
  }
  long long le = l;
  l = 0;
  r = N;
  while (l + 1 < r) {
    long long mid = (l + r) / 2;
    if (R(mid))
      r = mid;
    else
      l = mid;
  }
  long long ri = l;
  cout << max(0, ri - le) << "\n";
}
