#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
vector<int> c(200000, 0);
vector<vector<int> > td(200000, vector<int>(2, 0));
int bsL(int l, int r) {
  int mid = (l + r) / 2;
  if (mid == l || r == 0) {
    return l;
  }
  int now = mid;
  for (int i = 0; i < Q; i++) {
    if (c[now] == td[i][0]) {
      now += td[i][1];
    }
    if (now < 0) {
      return bsL(mid, r);
    } else if (now >= N) {
      break;
    }
  }
  return bsL(l, mid);
}
int bsR(int l, int r) {
  int mid = (l + r) / 2;
  if (mid == l) {
    return r;
  }
  int now = mid;
  for (int i = 0; i < Q; i++) {
    if (c[now] == td[i][0]) {
      now += td[i][1];
    }
    if (now >= N) {
      return bsR(l, mid);
    } else if (now < 0) {
      break;
    }
  }
  return bsR(mid, r);
}
int main() {
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < N; i++) {
    c[i] = s[i] - 'A';
  }
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    td[i][0] = t - 'A';
    if (d == 'L') {
      td[i][1] = -1;
    } else {
      td[i][1] = 1;
    }
  }
  int ans = N;
  ans -= bsL(-1, N) + 1;
  ans -= N - bsR(-1, N);
  cout << ans << endl;
}
