#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
char t[200000], d[200000];
int check[200000];
int jud(int n) {
  int pos = n;
  for (int i = 0; i < Q; i++) {
    char now = s[pos];
    if (t[i] == now) {
      if (d[i] == 'L') pos--;
      if (d[i] == 'R') pos++;
    }
    if (pos == -1) {
      return -1;
    } else if (pos == N) {
      return 1;
    }
  }
  return 0;
}
int bsl(int a, int b) {
  int p = (a + b) / 2;
  if (jud(p) == -1)
    check[p] = -1;
  else if (jud(p) == 0)
    check[p] = 0;
  else if (jud(p) == 1)
    check[p] = 1;
  if ((check[p] == 0 || check[p] == 1) && p == 0)
    return -1;
  else if (check[p] == -1 && (check[p + 1] == 0 || check[p + 1] == 1))
    return p;
  else if ((check[p] == 0 || check[p] == 1) && check[p - 1] == -1)
    return p - 1;
  else if (check[p] == -1) {
    return bsl(p, b);
  } else if (check[p] == 1 || check[p] == 0) {
    return bsl(a, p);
  }
}
int bsr(int a, int b) {
  int p = (a + b + 1) / 2;
  if (jud(p) == -1)
    check[p] = -1;
  else if (jud(p) == 0)
    check[p] = 0;
  else if (jud(p) == 1)
    check[p] = 1;
  if ((check[p] == -1 || check[p] == 0) && p == N - 1)
    return -1;
  else if (check[p] == 1 && (check[p - 1] == 0 || check[p - 1] == -1))
    return p;
  else if ((check[p] == 0 || check[p] == -1) && check[p + 1] == 1)
    return p + 1;
  else if (check[p] == 1) {
    return bsr(a, p);
  } else if (check[p] == -1 || check[p] == 0) {
    return bsr(p, b);
  }
}
int main() {
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  fill(check, check + 200000, 2);
  int l = bsl(0, N - 1);
  int r = bsr(0, N - 1);
  int ans = N;
  if (l != -1) {
    ans -= l + 1;
  }
  if (r != -1) {
    ans -= N - r;
  }
  cout << ans << endl;
  return 0;
}
