#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  vector<char> t(q), d(q);
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  long long a, b;
  {
    auto check = [&](int mid) {
      long long mmid = mid;
      for (int i = 0; i < q; ++i) {
        if (s[mmid] == t[i]) {
          if (d[i] == 'R')
            mmid += 1;
          else
            mmid -= 1;
        }
        if (mmid < 0) return true;
      }
      return false;
    };
    int l = 0, r = n - 1;
    while (r - l >= 0) {
      int mid = (l + r) / 2;
      if (check(mid)) {
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    a = l;
  }
  {
    auto check = [&](int mid) {
      long long mmid = mid;
      for (int i = 0; i < q; ++i) {
        if (s[mmid] == t[i]) {
          if (d[i] == 'R')
            mmid += 1;
          else
            mmid -= 1;
        }
        if (mmid >= n) return true;
      }
      return false;
    };
    int l = 0, r = n - 1;
    while (r - l >= 0) {
      int mid = (l + r) / 2;
      if (check(mid)) {
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    b = r;
  }
  cout << a << " " << b << endl;
  if (b - a < 0)
    cout << 0 << endl;
  else
    cout << b - a + 1 << endl;
}
