#include <bits/stdc++.h>
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const long long LINF = 1e18;
using namespace std;
long long n, cnt, ans, a, b, c, tmp, tmpp, m, h, w, x, y, sum, pos, k, q;
long double doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge {
  int to, cost;
};
char t[ohara], d[ohara];
bool check(long long iti) {
  long long now = iti;
  bool ok = true;
  for (int(i) = 0; (i) < (int)(q); (i)++) {
    if (s[now] != t[i]) continue;
    if (d[i] == 'R')
      now++;
    else
      now--;
    if (now == -1) {
      ok = false;
      break;
    }
  }
  return ok;
}
bool check2(long long iti) {
  long long now = iti;
  bool ok = true;
  for (int(i) = 0; (i) < (int)(q); (i)++) {
    if (s[now] != t[i]) continue;
    if (d[i] == 'R')
      now++;
    else
      now--;
    if (now == n) {
      ok = false;
      break;
    }
  }
  return ok;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q >> s;
  for (int(i) = 0; (i) < (int)(q); (i)++) cin >> t[i] >> d[i];
  long long le = 0, ri = n - 1, mid;
  while (ri - le > 1) {
    mid = (le + ri) / 2;
    if (check(mid))
      ri = mid;
    else
      le = mid;
  }
  for (int i = (max(le - 10, 0LL)); i < (min(ri + 10, n)); i++) {
    if (check(i)) {
      ans = i;
      break;
    }
  }
  le = 0, ri = n - 1, mid;
  while (ri - le > 1) {
    mid = (le + ri) / 2;
    if (!check2(mid))
      ri = mid;
    else
      le = mid;
  }
  for (int i = (min(ri + 10, n - 1)); i >= (max(le - 10, 0LL)); i--) {
    if (check2(i)) {
      ans += n - i - 1;
      break;
    }
  }
  cout << (max(n - ans, 0LL)) << endl;
  return 0;
}
