#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int n, q;
vector<char> field(200020);
vector<char> t(200020), d(200020);
int ans1 = 0, ans2 = 0;
bool isOk1(int now) {
  int tmp = now;
  for (int i = 0; i < q; i++) {
    char ns = field[tmp];
    if (ns == t[i]) {
      if (d[i] == 'L') {
        if (tmp - 1 < 0) {
          ans1 = max(ans1, now + 1);
          return true;
        } else
          tmp--;
      }
    }
  }
  return false;
}
bool isOk2(int now) {
  int tmp = now;
  for (int i = 0; i < q; i++) {
    char ns = field[tmp];
    if (ns == t[i]) {
      if (t[i] == 'R') {
        if (tmp + 1 >= n) {
          ans2 = max(ans2, n - now);
          return true;
        } else
          tmp++;
      }
    }
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> field[i];
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  int l = -1;
  int r = n / 2;
  while (r - l > 1) {
    int m = l + (r - l) / 2;
    if (isOk1(m))
      r = m;
    else
      l = m;
  }
  l = n / 2;
  r = n;
  while (r - l > 1) {
    int m = l + (r - l) / 2;
    if (isOk2(m))
      r = m;
    else
      l = m;
  }
  cout << n - (ans1 + ans2) << endl;
}
