#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool go_left(int index, const string& s, const vector<char>& t,
             const vector<char>& d) {
  for (int i = 0; i < t.size(); ++i) {
    char ti = t[i];
    char di = d[i];
    if (s[index] != ti) {
      continue;
    }
    if (di == 'L') {
      --index;
    } else {
      ++index;
    }
    if (index < 0) {
      return true;
    }
    if (s.size() <= index) {
      return false;
    }
  }
  return false;
}
bool go_right(int index, const string& s, const vector<char>& t,
              const vector<char>& d) {
  for (int i = 0; i < t.size(); ++i) {
    char ti = t[i];
    char di = d[i];
    if (s[index] != ti) {
      continue;
    }
    if (di == 'L') {
      --index;
    } else {
      ++index;
    }
    if (index < 0) {
      return false;
    }
    if (s.size() <= index) {
      return true;
    }
  }
  return false;
}
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q);
  vector<char> d(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> t[i] >> d[i];
  }
  vector<int> golems(N, 1);
  int ans = N;
  int left = 0;
  int right = N - 1;
  int center;
  while (left <= right) {
    center = (left + right) / 2;
    if (go_left(center, s, t, d)) {
      left = center + 1;
    } else {
      right = center - 1;
    }
  }
  std::cout << center << std::endl;
  ans -= center;
  left = 0;
  right = N - 1;
  while (left <= right) {
    center = (left + right) / 2;
    if (go_right(center, s, t, d)) {
      right = center - 1;
    } else {
      left = center + 1;
    }
  }
  std::cout << center << std::endl;
  ans -= (N - center);
  cout << ans << endl;
  return 0;
}
