#include <bits/stdc++.h>
using namespace std;
bool lessPair(const std::pair<int, int>& l, const std::pair<int, int>& r) {
  return l.second < r.second;
}
bool morePair(const std::pair<int, int>& l, const std::pair<int, int>& r) {
  return l.second > r.second;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  char t[Q], d[Q];
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  int left = -1;
  int right = N;
  int max_left = -1;
  int max_right = N;
  for (int q = Q - 1; q >= 0; q--) {
    if (d[q] == 'L' && t[q] == s[left + 1]) left++;
    if (left - 1 >= 0 && d[q] == 'R' && t[q] == s[left - 1]) left--;
    if (d[q] == 'R' && t[q] == s[right - 1]) right--;
    if (right + 1 <= N - 1 && d[q] == 'L' && t[q] == s[right + 1]) right++;
    if (left > max_left) max_left = left;
    if (right < max_right) max_right = right;
  }
  cout << max(max_right - max_left - 1, 0) << endl;
  return 0;
}
