#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string s;
  char t[200000] = {};
  char d[200000] = {};
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  int a[200000];
  for (int i = 0; i < N; i++) {
    a[i] = 1;
  }
  int k = 0;
  for (int i = 0; i < Q; i++) {
    if (d[i] == 'L') {
      for (int j = 0; j < N; j++) {
        if (s[j] == t[i]) {
          if (j == 0) {
            k += a[0];
            a[0] = 0;
          } else {
            a[j - 1] += a[j];
            a[j] = 0;
          }
        }
      }
    } else if (d[i] == 'R') {
      for (int j = N - 1; j >= 0; j--) {
        if (s[j] == t[i]) {
          if (j == N - 1) {
            k += a[N - 1];
            a[N - 1] = 0;
          } else {
            a[j + 1] += a[j];
            a[j] = 0;
          }
        }
      }
    }
  }
  cout << " " << N - k << endl;
  return 0;
}
