#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using pi = pair<int, int>;
using vpi = vector<pi>;
using pl = pair<ll, ll>;
using vpl = vector<pl>;
template <class T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T>
void print(std::vector<T> a) {
  int sz = a.size();
  for (int i = 0; i < a.size(); i++) cout << a[i] << (i < sz - 1 ? ' ' : '\n');
}
void ioboost() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
}
int n, q;
string s;
char t[200020], d[200020];
bool drop(int x) {
  int pos = x;
  char alp = s[x];
  for (int i = 0; i < q; i++) {
    if (alp == t[i]) {
      pos += (d[i] == 'R' ? 1 : -1);
      if (pos < 0 || pos >= n) return true;
      alp = s[pos];
    }
  }
  return false;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  int L, R;
  int l = -1, r = n;
  while (l + 1 != r) {
    int mid = (l + r) / 2;
    if (drop(mid))
      l = mid;
    else
      r = mid;
  }
  L = l;
  l = -1, r = n;
  while (l + 1 != r) {
    int mid = (l + r) / 2;
    if (drop(mid))
      r = mid;
    else
      l = mid;
  }
  R = l;
  cout << R - L << '\n';
}
