#include <bits/stdc++.h>
using namespace std;
char t[200000], d[200000];
int main() {
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  int drop_r = 0;
  char ng = 'n';
  int pointer = N - 1;
  for (int i = Q - 1; i >= 0; i--) {
    if (t[i] == ng && d[i] == 'L') {
      drop_r = max(drop_r, (N - 1) - (pointer + 1));
      ng = 'n';
      pointer = N - 1;
    }
    if (t[i] == s[pointer] && d[i] == 'R') {
      ng = s[pointer];
      pointer--;
      if (pointer < 0) {
        break;
      }
    }
  }
  drop_r = max(drop_r, (N - 1) - pointer);
  int drop_l = 0;
  ng = 'n';
  pointer = 0;
  for (int i = Q - 1; i >= 0; i--) {
    if (t[i] == ng && d[i] == 'R') {
      drop_l = max(drop_l, pointer - 1);
      ng = 'n';
      pointer = 0;
    }
    if (t[i] == s[pointer] && d[i] == 'L') {
      ng = s[pointer];
      pointer++;
      if (pointer >= N) {
        break;
      }
    }
  }
  drop_l = max(drop_l, pointer);
  int ans = N - (drop_r + drop_l);
  if (ans < 0) {
    ans = 0;
  }
  cout << drop_l << ", " << drop_r << endl;
  cout << ans << endl;
}
