#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<char> T(Q), D(Q);
  for (int i = 0; i < Q; i++)
    cin >> T[i] >> D[i];
  int left = 0, right = N - 1;
  for (int i = Q - 1; i >= 0; i--) {
    if (D[i] == 'L') {
      if (T[i] == S[left]) left++;
      if (right < N - 1 && T[i] == S[right + 1]) right++;
    } else {
      if (T[i] == S[right]) right--;
      if (left > 0 && T[i] == S[left - 1]) left--;
    }
  }
  cout << max(right - left + 1, 0) << '\n';
  return 0;
}
