#include <bits/stdc++.h>
using namespace std;
class aaa {
 public:
  char s;
  int num;
};
int main() {
  int N, Q, ans = 0, min, max, k;
  cin >> N >> Q;
  aaa ccc[N + 2];
  for (int i = 1; i < N + 1; i++) {
    cin >> ccc[i].s;
    ccc[i].num = 1;
  }
  char t[Q], d[Q];
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  k = N + 1;
  for (int i = Q - 1; i >= 0; i--) {
    if (t[i] == ccc[k - 1].s && d[i] == 'R') {
      if (k == 0) {
        break;
      } else {
        k -= 1;
      }
    }
  }
  min = k;
  k = 0;
  for (int i = Q - 1; i >= 0; i--) {
    if (t[i] == ccc[k + 1].s && d[i] == 'L') {
      if (k == N + 1) {
        break;
      } else {
        k += 1;
      }
    }
  }
  max = k;
  ans = (min - max - 1) > 0 ? min - max - 1 : 0;
  cout << ans << endl;
  return 0;
}
