#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, q;
char a[N];
char c[N];
char d[N];
bool isval1(int k) {
  int pos = k;
  for (int i = 0; i < q; i++) {
    if (a[pos] == c[i]) {
      if (d[i] == 'L') {
        pos--;
      } else {
        pos++;
      }
      if (pos == -1) return true;
    }
  }
  return false;
}
int bsearch1() {
  int down = -1;
  int up = n;
  while (up - down > 1) {
    int md = (up + down) / 2;
    if (isval1(md)) {
      down = md;
    } else {
      up = md;
    }
  }
  return down;
}
bool isval2(int k) {
  int pos = k;
  for (int i = 0; i < n; i++) {
    if (a[pos] == c[i]) {
      if (d[i] == 'L') {
        pos++;
      } else {
        pos--;
      }
      if (pos == -1) return true;
    }
  }
  return false;
}
int bsearch2() {
  int down = -1;
  int up = n;
  while (up - down > 1) {
    int md = (up + down) / 2;
    if (isval2(md)) {
      down = md;
    } else {
      up = md;
    }
  }
  return down;
}
int main() {
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < q; i++) {
    cin >> c[i] >> d[i];
  }
  int ans = 0;
  ans = bsearch1();
  reverse(a, a + n);
  ans += bsearch2();
  ans++;
  ans++;
  cout << n - ans << endl;
}
