#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = std::vector<T>;
template <class T>
using vvec = vec<vec<T>>;
constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }
int main() {
  using namespace std;
  int n, q;
  string s;
  cin >> n >> q >> s;
  s = "  " + s + "  ";
  int l = {1}, r{n + 2};
  int lmax{l}, rmin{r};
  vec<pair<char, char>> v(q);
  for (auto &e : v) {
    cin >> e.first >> e.second;
  }
  vec<bool> reached(n + 2);
  for (int i = q - 1; i >= 0; --i) {
    if (v[i].second == 'R') {
      if (s[r - 1] == v[i].first) --r;
      if (s[l - 1] == v[i].first) --l;
    } else {
      if (s[l + 1] == v[i].first) ++l;
      if (s[r + 1] == v[i].first) ++r;
    }
    lmax = max({l, lmax});
    rmin = min({r, rmin});
  }
  cout << l << " " << r << endl;
  cout << lmax << " " << rmin << endl;
  cout << max({0, rmin - lmax - 1}) << endl;
  return 0;
}
