#include <bits/stdc++.h>
using namespace std;
const int INFINT = 1 << 30;
const long long INFLL = 1LL << 60;
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX_N = 200000, MAX_Q = 200000;
int N, Q;
string s;
char t[MAX_Q], d[MAX_Q];
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N >> Q;
  cin >> 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) {
    int nl = l + 1, nr = r - 1;
    if (nl < N && s[nl] == t[i] && d[i] == 'L') {
      ++l;
    }
    if (nr >= 0 && s[nr] == t[i] && d[i] == 'R') {
      --r;
    }
  }
  cout << N - (l + 1) - (N - r) << endl;
  return 0;
}
