#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
struct edge {
  long long to, cost, val;
};
template <class T, class U>
bool chmin(T& a, const U& b) {
  if (a <= b) return false;
  a = b;
  return true;
}
template <class T, class U>
bool chmax(T& a, const U& b) {
  if (a >= b) return false;
  a = b;
  return true;
}
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, -1, 1};
int N, Q;
string S;
vector<char> t, d;
bool checkR(int x) {
  for (int i = 0; i < Q; i++) {
    if (S[x] == t[i]) {
      if (d[i] == 'L')
        x--;
      else
        x++;
    }
    if (x == -1) return false;
    if (x == N) return true;
  }
  return false;
}
bool checkL(int x) {
  for (int i = 0; i < Q; i++) {
    if (S[x] == t[i]) {
      if (d[i] == 'L')
        x--;
      else
        x++;
    }
    if (x == -1) return true;
    if (x == N) return false;
  }
  return false;
}
signed main() {
  cin >> N >> Q >> S;
  t.resize(Q);
  d.resize(Q);
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int ok = N, ng = -1;
  while (ok - ng != 1) {
    int mid = (ng + ok) / 2;
    if (checkR(mid))
      ok = mid;
    else
      ng = mid;
  }
  int r = ok;
  ok = -1, ng = N;
  while (ng - ok != 1) {
    int mid = (ng + ok) / 2;
    if (checkL(mid))
      ok = mid;
    else
      ng = mid;
  }
  int l = ok;
  cout << r << " " << l << endl;
  if (l >= r)
    cout << N << endl;
  else
    cout << N - ((N - 1 - r + 1) + (l + 1)) << endl;
}
