#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void chmin(T &a, T b) {
  if (a >= b) a = b;
}
template <class T>
inline void chmax(T &a, T b) {
  if (a <= b) a = b;
}
int N, Q;
string s;
char t[210000], d[210000];
int main() {
  int N, Q;
  string s;
  cin >> N >> Q >> s;
  for (int i = 0; i < (Q); ++i) cin >> t[i] >> d[i];
  int L = -1, R = N;
  for (int i = Q - 1; i >= 0; --i) {
    if (d[i] == 'L') {
      if (L + 1 < N && s[L + 1] == t[i]) {
        ++L;
      }
      if (R < N && s[R] == t[i]) {
        ++R;
      }
    } else {
      if (L > 0 && s[L] == t[i]) {
        --L;
      }
      if (R - 1 > 0 && s[R - 1] == t[i]) {
        --R;
      }
    }
    if (L + 1 >= R) break;
  }
  cout << max(R - L - 1, 0) << endl;
}
