#include <bits/stdc++.h>
using namespace std;
signed main() {
  int64_t N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<char> T(N), D(N);
  for (int64_t(i) = 0; (i) < (Q); (i)++) cin >> T[i] >> D[i];
  int64_t left = 0, right = N;
  while (left + 1 < right) {
    int64_t mid = (left + right) / 2;
    int64_t idx = mid;
    bool leftside = false;
    for (int64_t(i) = 0; (i) < (Q); (i)++) {
      if (S[idx] == T[i]) {
        if (D[i] == 'R')
          idx++;
        else
          idx--;
      }
      if (idx == -1) {
        leftside = true;
        break;
      } else if (idx == N)
        break;
    }
    if (leftside)
      left = mid;
    else
      right = mid;
    cout << left << " " << mid << " " << right << endl;
  }
  int64_t ans = N;
  ans -= left + 1;
  left = 0, right = N;
  while (left + 1 < right) {
    int64_t mid = (left + right) / 2;
    int64_t idx = mid;
    bool rightside = false;
    for (int64_t(i) = 0; (i) < (Q); (i)++) {
      if (S[idx] == T[i]) {
        if (D[i] == 'R')
          idx++;
        else
          idx--;
      }
      if (idx == -1)
        break;
      else if (idx == N) {
        rightside = true;
        break;
      }
    }
    if (rightside)
      right = mid;
    else
      left = mid;
  }
  ans -= N - right;
  cout << ans << endl;
}
