#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using G = vector<vector<int>>;
int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
int n, q;
char t[200005];
int d[200005];
string s;
int isOut(int k) {
  if (k < 0) return -1;
  if (k >= n) return +1;
  int now = k;
  for (int i = (0); i < (q); i++) {
    if (s[now] == t[i]) {
      now += d[i];
    }
    if (now < 0) return -1;
    if (now >= n) return +1;
  }
  return 0;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  cin >> s;
  for (int i = (0); i < (q); i++) {
    char dd;
    cin >> t[i] >> dd;
    if (dd == 'L') {
      d[i] = -1;
    } else {
      d[i] = +1;
    }
  }
  if (n == 1) {
    if (isOut(0) == 0) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }
  int ok = -1;
  int ng = n - 1;
  while (ng - ok > 1) {
    int c = (ok + ng) / 2;
    if (isOut(c) == -1) {
      ok = c;
    } else {
      ng = c;
    }
  }
  int l = ok;
  ok = n;
  ng = 0;
  while (ok - ng > 1) {
    int c = (ok + ng) / 2;
    if (isOut(c) == +1) {
      ok = c;
    } else {
      ng = c;
    }
  }
  int r = ok;
  cout << r - l - 1 << endl;
  return 0;
}
