#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string s;
ll N, Q;
vector<char> t(20000);
vector<char> d(20000);
int simulation(int pos) {
  for (int i = 0; i < Q; ++i) {
    if (pos == 0) return -1;
    if (pos == N + 1) return 1;
    if (s[pos - 1] == t[i]) {
      if (d[i] == 'R')
        pos++;
      else
        pos--;
    }
  }
  if (pos == 0) return -1;
  if (pos == N + 1) return 1;
  return 0;
}
int main() {
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < Q; ++i) {
    cin >> t[i] >> d[i];
  }
  int L1 = 0, R1 = N + 1, M1, maxn = 0;
  while (L1 + 1 < R1) {
    M1 = (L1 + R1) / 2;
    int a = simulation(M1);
    if (a == -1) {
      maxn = max(maxn, M1);
      L1 = M1;
    } else {
      R1 = M1;
    }
  }
  int L2 = 0, R2 = N + 1, M2, minn = N + 1;
  while (L2 + 1 < R2) {
    M2 = (L2 + R2) / 2;
    int a = simulation(M2);
    if (a == 1) {
      minn = min(minn, M2);
      R2 = M2;
    } else {
      L2 = M2;
    }
  }
  cout << minn - maxn - 1 << endl;
}
