#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, ans = 0;
  string s;
  char t, d;
  cin >> n >> q >> s;
  char que[q][2];
  for (int i = 0; i < q; i++) cin >> que[i][0] >> que[i][1];
  int l = 0, r = 0;
  for (int i = q - 1; i >= 0; i--) {
    if (que[i][1] == 'L') {
      if (s[l] == que[i][0]) l++;
    } else {
      if (s[n - r - 1] == que[i][0]) r++;
    }
    if (l + r == n) goto E;
  }
E:
  cout << n - (l + r) << endl;
  return 0;
}
