#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
constexpr ll INF = 1000000000;
void sub_main(istream &cin) {
  ll N, Q;
  cin >> N >> Q;
  if (!cin) return;
  string L, R;
  string S;
  cin >> S;
  for (int i = 0; i < Q; ++i) {
    char t, d;
    cin >> t >> d;
    if (d == 'L')
      L.push_back(t);
    else
      R.push_back(t);
  }
  int l, r;
  l = 0;
  r = S.size() - 1;
  auto lp = L.rbegin();
  while (lp != L.rend()) {
    if (S[l] == *lp) l++;
    lp++;
  }
  auto rp = R.rbegin();
  while (rp != R.rend()) {
    if (S[r] == *rp) r--;
    rp++;
  }
  ll ans = r - l + 1;
  if (ans < 0) ans = 0;
  cout << ans << endl;
}
int main(int argc, char *argv[]) {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(16) << scientific;
  sub_main(cin);
  return 0;
}
