#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int N, Q;
string s;
vector<char> t, d;
bool lf(int k) {
  int now = k;
  for (int i = 0; i < Q; i++) {
    if (s[now] == t[i]) {
      if (d[i] == 'L')
        now--;
      else
        now++;
    }
    if (now < 0) return true;
  }
  return false;
}
bool rf(int k) {
  int now = k;
  for (int i = 0; i < Q; i++) {
    if (s[now] == t[i]) {
      if (d[i] == 'L')
        now--;
      else
        now++;
    }
    if (now >= N) return true;
  }
  return false;
}
int main() {
  cin >> N >> Q >> s;
  t.resize(N);
  d.resize(N);
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int l, r;
  {
    int ok = -1;
    int ng = N;
    while (ng - ok > 1) {
      int mid = (ok + ng) / 2;
      if (lf(mid))
        ok = mid;
      else
        ng = mid;
    }
    l = ok;
  }
  {
    int ok = N;
    int ng = -1;
    while (ok - ng > 1) {
      int mid = (ok + ng) / 2;
      if (rf(mid))
        ok = mid;
      else
        ng = mid;
    }
    r = ok;
  }
  cout << l << " " << r << endl;
  cout << N - ((N - r) + (l + 1)) << endl;
}
