#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
string S;
vector<pair<char, char> > Q;
int t;
int N;
bool check(int index, bool direcction) {
  char c = S[index];
  for (auto it : Q) {
    if (c == it.first) {
      if (it.second == 'L') {
        index--;
      } else {
        index++;
      }
      if (direcction) {
        if (index < 1) return true;
      } else {
        if (index > N) return true;
      }
      c = S[index];
    }
  }
  return false;
}
int find_me(int left, int right, bool direction) {
  int ans = left - 1;
  if (!direction) ans = right + 1;
  while (left <= right) {
    int mid = (left + right) / 2;
    if (check(mid, direction)) {
      ans = mid;
      if (direction) {
        left = mid + 1;
      } else {
        right = mid - 1;
      }
    } else {
      if (direction) {
        right = mid - 1;
      } else {
        left = mid + 1;
      }
    }
  }
  return ans;
}
int main() {
  cin >> N >> t;
  cin >> S;
  S = "0" + S + "0";
  for (char a, b; t--;) {
    cin >> a >> b;
    Q.push_back({a, b});
  }
  int rs = find_me(1, N, true);
  int lim = rs;
  int rs2 = N - find_me(lim + 1, N, false) + 1;
  cout << rs << " " << rs2 << endl;
  cout << N - (rs + rs2);
  return 0;
}
