#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  struct Spel {
    char c;
    int d;
  };
  vector<Spel> spels(q);
  for (auto& spel : spels) {
    char c, d;
    cin >> c >> d;
    spel.c = c;
    spel.d = (d == 'L') ? -1 : 1;
  }
  vector<int> e_ls(q);
  vector<int> e_rs(q);
  int e_l = 0;
  int e_r = n - 1;
  for (int i = 0; i < q; i++) {
    const auto& spel = spels[i];
    if (e_l < n) {
      if (spel.c == s[e_l] && spel.d == 1) {
        e_l++;
      }
    }
    if (0 <= e_r) {
      if (spel.c == s[e_r] && spel.d == -1) {
        e_r--;
      }
    }
    e_ls[i] = e_l;
    e_rs[i] = e_r;
  }
  int p_l = 0;
  int p_r = n - 1;
  int fall_l = 0;
  int fall_r = 0;
  for (int i = q - 1; 0 <= i; i--) {
    const auto& spel = spels[i];
    if (p_l < n) {
      if (spel.c == s[p_l] && spel.d == -1) {
        p_l++;
        if (e_ls[i] < p_l) {
          fall_l = p_l;
        }
      }
    }
    if (0 <= p_r) {
      if (spel.c == s[p_r] && spel.d == 1) {
        p_r--;
        if (p_r < e_rs[i]) {
          fall_r = (n - 1 - p_r);
        }
      }
    }
  }
  int fall_count = min(n, fall_l + fall_r);
  cout << (n - fall_count) << endl;
  return 0;
}
