#include <bits/stdc++.h>
using namespace std;
int cha(char c) {
  if (c == 'A') return 0;
  if (c == 'B') return 1;
  if (c == 'C') return 2;
  if (c == 'D') return 3;
  if (c == 'E') return 4;
  if (c == 'F') return 5;
  if (c == 'G') return 6;
  if (c == 'H') return 7;
  if (c == 'I') return 8;
  if (c == 'J') return 9;
  if (c == 'K') return 10;
  if (c == 'L') return 11;
  if (c == 'M') return 12;
  if (c == 'N') return 13;
  if (c == 'O') return 14;
  if (c == 'P') return 15;
  if (c == 'Q') return 16;
  if (c == 'R') return 17;
  if (c == 'S') return 18;
  if (c == 'T') return 19;
  if (c == 'U') return 20;
  if (c == 'V') return 21;
  if (c == 'W') return 22;
  if (c == 'X') return 23;
  if (c == 'Y') return 24;
  if (c == 'Z') return 25;
  return '0';
}
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> a(q);
  vector<bool> b(q, false);
  for (int i = 0; i < q; i++) {
    char x, y;
    cin >> x >> y;
    a[i] = cha(x);
    if (y == 'R') b[i] = true;
  }
  int x = 0, y = s[0], an = 0, ans = n;
  for (int i = n - 1; i < -1; i--) {
    if (y == a[i]) {
      if (!b[i])
        x++;
      else {
        if (x != 0) x--;
      }
    }
    if (x == n) {
      x--;
      break;
    }
    y = s[x];
    if (an < x) an++;
  }
  x = n - 1;
  y = s[n - 1];
  for (int i = q - 1; i > -1; i--) {
    if (y == a[i]) {
      if (b[i])
        x--;
      else {
        if (x != n - 1) x++;
      }
    }
    if (x == -1) {
      x++;
      break;
    }
    y = s[x];
    if (ans > x) ans--;
  }
  if (ans - an < 0)
    cout << ans - an << endl;
  else
    cout << ans - an << endl;
  cout << an << " " << ans << endl;
}
