#include <bits/stdc++.h>
using namespace std;
int fall(vector<char> &t, vector<char> &d, const string &s, int N, int pos) {
  for (int i = 0; i < (int)(t.size()); i++) {
    if (t[i] == s[pos]) {
      pos += (d[i] == 'L') ? -1 : 1;
    }
    if (pos < 0) return -1;
    if (pos > N - 1) return 1;
  }
  return 0;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q);
  vector<char> d(Q);
  for (int i = 0; i < (int)(Q); i++) cin >> t[i] >> d[i];
  int res = N;
  int a = 0;
  int b = N - 1;
  int c;
  int xa = fall(t, d, s, N, a);
  int xb = fall(t, d, s, N, b);
  int target = 0;
  while (a <= b) {
    c = (a + b) / 2;
    int xc_ = fall(t, d, s, N, c - 1);
    int xc = fall(t, d, s, N, c);
    if (c == 0 || (xc_ < target && xc == target))
      break;
    else if (xc < target)
      a = c + 1;
    else
      b = c - 1;
  }
  int leftmost = c;
  a = 0;
  b = N - 1;
  xa = fall(t, d, s, N, a);
  xb = fall(t, d, s, N, b);
  while (a <= b) {
    c = (a + b) / 2;
    int xc_ = fall(t, d, s, N, c - 1);
    int xc = fall(t, d, s, N, c);
    if (c == N - 1 || xc_ == target && xc > target)
      break;
    else if (xc_ <= target)
      a = c + 1;
    else
      b = c - 1;
  }
  int rightmost = ((c == N - 1) ? c : (c - 1));
  cout << rightmost - leftmost + 1 << endl;
  return 0;
}
