#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX = 1e5;
int N, Q;
string s;
char t[MAX + 10], d[MAX + 10];
int simulate(int idx) {
  for (int i = 0; i < Q; i++) {
    if (t[i] != s[idx]) continue;
    (d[i] == 'L' ? idx-- : idx++);
    if (idx < 0 || idx >= N) break;
  }
  return idx;
}
bool isLeftFall(int idx) { return simulate(idx) < 0; }
bool isRightFall(int idx) { return simulate(idx) >= N; }
int main() {
  cin >> N >> Q >> s;
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int l = 0, r = N - 1;
  while (l < r) {
    int mid = (l + r) / 2;
    if (isLeftFall(mid)) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  int left = l;
  l = 0, r = N - 1;
  while (l < r) {
    int mid = (l + r) / 2;
    if (isRightFall(mid)) {
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  int right = r;
  cout << max(right - left, 0) << endl;
  return 0;
}
