#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, Q;
string s;
vector<char> t(Q);
bool checkLeft(int x, vector<char> &d) {
  for (int i = 0; i < t.size(); i++) {
    if (t[i] == s[x]) {
      x += (d[i] == 'L' ? -1 : 1);
    }
    if (s[x] == '_') {
      return x == 0;
    }
    return false;
  }
}
int main() {
  cin >> N >> Q;
  cin >> s;
  vector<vector<char>> d(2, vector<char>(Q));
  s = '_' + s + '_';
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[0][i];
    d[1][i] = (d[0][i] == 'L' ? 'R' : 'L');
  }
  int golem = N;
  for (int i = 0; i < 2; i++) {
    int lb = 0, m, ub = N + 1;
    while (ub - lb > 1) {
      m = (ub + lb) / 2;
      (checkLeft(m, d[i]) ? lb : ub) = m;
    }
    golem = lb;
    reverse(s.begin(), s.end());
  }
  cout << golem << endl;
  return 0;
}
