#include <bits/stdc++.h>
using namespace std;
int move_golem(int ini, string s, string t, string d) {
  int golem_temp = ini;
  for (int i = 0; i < t.size(); i++) {
    if ((golem_temp == -1) || (golem_temp == s.size())) {
      break;
    }
    if (s[golem_temp] == t[i]) {
      if (d[i] == 'L') {
        golem_temp = golem_temp - 1;
      } else if (d[i] == 'R') {
        golem_temp = golem_temp + 1;
      }
    }
  }
  return golem_temp;
}
int main() {
  int N;
  int Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  string t(Q, 'a');
  string d(Q, 'a');
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  int lb = -1;
  int ub = s.size();
  int lower_bound = 0;
  while ((ub - lb) > 1) {
    int mid = (lb + ub) / 2;
    int mid_golem_temp = move_golem(mid, s, t, d);
    if (mid_golem_temp > -1) {
      ub = mid;
    } else {
      lb = mid;
    }
    lower_bound = lb;
  }
  lb = -1;
  ub = s.size();
  int upper_bound = 0;
  while ((ub - lb) > 1) {
    int mid = (lb + ub) / 2;
    int mid_golem_temp = move_golem(mid, s, t, d);
    if (mid_golem_temp < s.size()) {
      lb = mid;
    } else {
      ub = mid;
    }
    upper_bound = ub;
  }
  cout << upper_bound - lower_bound - 1 << endl;
  return 0;
}
