#include <bits/stdc++.h>
using namespace std;
vector<int> lmov[26], rmov[26];
int tp[100005];
int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    char a;
    cin >> a;
    tp[i] = (int)(a - 'A');
  }
  for (int i = 0; i < q; i++) {
    char a, b;
    cin >> a >> b;
    int idx = (int)(a - 'A');
    if (b == 'L')
      lmov[idx].push_back(i);
    else
      rmov[idx].push_back(i);
  }
  int l = -1, tl = 0;
  if (lmov[tp[0]].size() > 0) {
    tl = lmov[tp[0]][lmov[tp[0]].size() - 1];
    l = 0;
  }
  while (1) {
    int nidx = tp[l + 1];
    int num = lower_bound(lmov[nidx].begin(), lmov[nidx].end(), tl) -
              lmov[nidx].begin();
    num--;
    if (num >= 0) {
      l++;
      tl = lmov[nidx][num];
    } else
      break;
  }
  int r = n, tr = 0;
  if (rmov[tp[n - 1]].size() > 0) {
    tr = rmov[tp[n - 1]][rmov[tp[n - 1]].size() - 1];
    r = n - 1;
  }
  while (1) {
    int nidx = tp[r - 1];
    int num = lower_bound(rmov[nidx].begin(), rmov[nidx].end(), tr) -
              rmov[nidx].begin();
    num--;
    if (num >= 0) {
      r--;
      tr = rmov[nidx][num];
    } else
      break;
  }
  cout << max(0, min(n, r - l - 1)) << endl;
}
