#include <bits/stdc++.h>
using namespace std;
void printv(vector<int> &v) {
  for (auto item : v) cout << item << " ";
  cout << endl;
}
void printvv(vector<vector<int>> &v) {
  for (auto item : v) printv(item);
  cout << endl;
}
int travelL(int N, int Q, string s, vector<char> t, vector<char> d) {
  int lpos = -1;
  for (int i = Q - 1; i >= 0; i--) {
    if (lpos >= 0 && t[i] == s[lpos] && d[i] == 'R') {
      return lpos;
    } else if (lpos + 1 < N && t[i] == s[lpos + 1] && d[i] == 'L') {
      lpos++;
    }
  }
  return lpos + 1;
}
int travelR(int N, int Q, string s, vector<char> t, vector<char> d) {
  int rpos = N;
  for (int i = Q - 1; i >= 0; i--) {
    if (rpos < N && t[i] == s[rpos] && d[i] == 'L') {
      return rpos;
    } else if (rpos - 1 >= 0 && t[i] == s[rpos - 1] && d[i] == 'R') {
      rpos--;
    }
  }
  return N - rpos;
}
int main() {
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  vector<char> t(Q), d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  auto l = travelL(N, Q, s, t, d);
  auto r = travelR(N, Q, s, t, d);
  cout << max(N - l - r, 0) << endl;
}
