#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
int main() {
  int N, Q;
  string s;
  cin >> N >> Q >> s;
  vector<char> t(Q);
  vector<char> d(Q);
  for (int i = Q - 1; i >= 0; i--) cin >> t.at(i) >> d.at(i);
  int max_left = -1;
  int min_right = N;
  int left = -1;
  int right = N;
  for (int i = 0; i < Q; i++) {
    if (left + 1 < s.size() && t.at(i) == s.at(left + 1) && d.at(i) == 'L')
      left++;
    if (left - 1 >= 0 && t.at(i) == s.at(left - 1) && d.at(i) == 'R') left++;
    if (right - 1 >= 0 && t.at(i) == s.at(right - 1) && d.at(i) == 'R') right--;
    if (right + 1 < s.size() && t.at(i) == s.at(right + 1) && d.at(i) == 'L')
      left++;
    max_left = max(max_left, left);
    min_right = min(min_right, right);
  }
  cout << max(0, min_right - max_left - 1) << endl;
  return 0;
}
