#include <bits/stdc++.h>
using namespace std;
using LONG = long long int;
using ULONG = unsigned long long int;
using namespace std;
int N, Q;
string s;
vector<char> t;
vector<char> d;
bool drop(int index) {
  for (int i = 0; i < N; ++i) {
    if (s[index] == t[i]) {
      if (d[i] == 'L') {
        index--;
      } else {
        index++;
      }
    }
    if (index < 0 || index >= N) return true;
  }
  return false;
}
int solve() {
  int ok = 0, ng = N;
  while (abs(ng - ok) > 1) {
    int mid = (ok + ng) / 2;
    if (drop(mid)) {
      ng = mid;
    } else {
      ok = mid;
    }
  }
  int ok1 = ok, ng1 = -1;
  while (abs(ok1 - ng1) > 1) {
    int mid = (ok1 + ng1) / 2;
    if (drop(mid)) {
      ng1 = mid;
    } else {
      ok1 = mid;
    }
  }
  int ok2 = ok, ng2 = N;
  while (abs(ok2 - ng2) > 1) {
    int mid = (ok2 + ng2) / 2;
    if (drop(mid)) {
      ng2 = mid;
    } else {
      ok2 = mid;
    }
  }
  cout << ok << endl << ok1 << endl << ok2 << endl;
  return N - (ok1 + (N - 1 - ok2));
}
int main() {
  cin >> N >> Q;
  cin >> s;
  t.resize(Q);
  d.resize(Q);
  for (unsigned int i = 0; i < Q; ++i) cin >> t[i] >> d[i];
  cout << solve() << endl;
}
