#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const long long NMAX = 2e5;
long long n, q;
string s;
vector<char> a(NMAX), b(NMAX);
bool check(long long mid) {
  long long id = mid - 1;
  for (long long i = (0); i < (q); i++) {
    if (s[id] != a[i]) continue;
    if (b[i] == 'L')
      id--;
    else
      id++;
    if (id == -1) return true;
    if (id == n) return false;
  }
  return false;
}
bool check2(long long mid) {
  long long id = mid - 1;
  for (long long i = (0); i < (q); i++) {
    if (s[id] != a[i]) continue;
    if (b[i] == 'L')
      id++;
    else
      id--;
    if (id == -1) return true;
    if (id == n) return false;
  }
  return false;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q >> s;
  for (long long i = (0); i < (q); i++) cin >> a[i] >> b[i];
  long long ng = n, ok = 0;
  while (abs(ng - ok) > 1) {
    long long mid = (ng + ok) / 2;
    (check(mid) ? ok : ng) = mid;
  }
  long long l = ok;
  reverse(s.begin(), s.end());
  ng = n, ok = 0;
  while (abs(ng - ok) > 1) {
    long long mid = (ng + ok) / 2;
    (check2(mid) ? ok : ng) = mid;
  }
  cout << n - ok - l << endl;
  return 0;
}
