#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5;
int main() {
  int N, Q;
  cin >> N >> Q;
  char s[MAX], t[MAX], d[MAX];
  s[0] = '0', s[N + 1] = '0';
  for (int i = 1; i <= (int)(N); i++) cin >> s[i];
  for (int i = 1; i <= (int)(Q); i++) cin >> t[i] >> d[i];
  int x = 0, y = N + 1;
  for (int i = Q; i >= 1; i--) {
    if (s[x + 1] == t[i] && d[i] == 'L') x++;
    if (s[y - 1] == t[i] && d[i] == 'R') y--;
  }
  cout << y - x - 1 << endl;
}
