#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  string t, d;
  for (int i = 0; i < q; i++) {
    char t0, d0;
    cin >> t0 >> d0;
    t += t0, d += d0;
  }
  int r = n - 1;
  int l = 0;
  for (int i = q - 1; i >= 0; i--) {
    if (t[i] == s[r] && d[i] == 'R') r--;
  }
  for (int i = q - 1; i >= 0; i--) {
    if (t[i] == s[l] && d[i] == 'L') l++;
  }
  cout << max(0, r - l + 1) << endl;
  return 0;
}
