#include <bits/stdc++.h>
using namespace std;
int n, q;
string second;
pair<char, char> td[200005];
bool chlf(int loc) {
  int cl = loc;
  for (int i = 0; i < (q); i++) {
    if (second[cl] == td[i].first) {
      if (td[i].second == 'L')
        cl--;
      else
        cl++;
    }
    if (cl == -1) return true;
    if (cl == n) return false;
  }
  return false;
}
bool chrt(int loc) {
  int cl = loc;
  for (int i = 0; i < (q); i++) {
    if (second[cl] == td[i].first) {
      if (td[i].second == 'L')
        cl--;
      else
        cl++;
    }
    if (cl == -1) return false;
    if (cl == n) return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> q;
  cin >> second;
  for (int i = 0; i < (q); i++) {
    cin >> td[i].first >> td[i].second;
  }
  int l = -1, r = n - 1;
  while (l + 1 < r) {
    int mid = (l + r) / 2;
    if (chlf(mid))
      l = mid;
    else
      r = mid;
  }
  int l2 = 0, r2 = n;
  while (l2 + 1 < r2) {
    int mid = (l2 + r2) / 2;
    if (chrt(mid))
      r2 = mid;
    else
      l2 = mid;
  }
  int lst = l + 1, rst = r2 - 1;
  cout << l << " " << r2 << "\n";
  cout << max(rst - lst + 1, 0) << "\n";
  return 0;
}
