#include <bits/stdc++.h>
using namespace std;
int drop;
string s;
int N;
int Q;
vector<char> t;
vector<char> d;
bool judge(int x) {
  int now = x;
  for (int i = 1; i <= Q; i++) {
    if (s[now] != t[i]) continue;
    if (d[i] == 'R')
      now++;
    else
      now--;
    if (now < 1) return true;
  }
  return false;
}
bool judge2(int x) {
  int now = x;
  for (int i = 1; i <= Q; i++) {
    if (s[now] != t[i]) continue;
    if (d[i] == 'R')
      now++;
    else
      now--;
    if (now > N) return true;
  }
  return false;
}
int main() {
  cin >> N;
  cin >> Q;
  t.resize(Q + 10);
  d.resize(Q + 10);
  cin >> s;
  s = '#' + s;
  s = s + '#';
  for (int i = 1; i <= Q; i++) {
    cin >> t[i] >> d[i];
  }
  int Lans = 10000000;
  int left = 1;
  int right = N + 1;
  int mid = N / 2;
  int ans = mid;
  while (right - left > 1) {
    if (judge(mid)) {
      left = mid;
      mid = (left + right) / 2;
    } else {
      right = mid;
      mid = (left + right) / 2;
    }
  }
  if (judge(mid)) Lans = mid;
  int Rans = 10000000;
  left = 0;
  right = N;
  mid = N / 2;
  ans = mid;
  while (right - left > 1) {
    if (judge2(mid)) {
      right = mid;
      mid = (left + right) / 2;
    } else {
      left = mid;
      mid = (left + right) / 2;
    }
  }
  if (judge2(mid - 1)) Rans = mid - 1;
  for (int i = 1; i <= N; i++) {
    if (1 <= i and i <= Lans) {
      drop++;
      continue;
    }
    if (Rans <= i and i <= N) drop++;
  }
  cout << Lans << " " << Rans << endl;
  cout << N - drop << endl;
  return 0;
}
