#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<string> t(Q);
  vector<string> d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  int pos_l = 0;
  int pos_r = N - 1;
  for (int i = Q - 1; i >= 0; i--) {
    if (d[i] == "R") {
      if (pos_l - 1 >= 0) {
        if (s[pos_l - 1] == t[i][0]) pos_l--;
      }
      if (s[pos_r] == t[i][0]) pos_r--;
    } else {
      if (pos_r + 1 < N) {
        if (s[pos_r + 1] == t[i][0]) pos_r++;
      }
      if (s[pos_l] == t[i][0]) pos_l++;
    }
  }
  cout << pos_l << " " << pos_r << endl;
  cout << pos_r - pos_l + 1 << endl;
  return 0;
}
