#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
vector<char> t(300000);
vector<char> d(300000);
int main() {
  cin >> n >> q >> s;
  for (int i = 0; i < q; ++i) {
    cin >> t.at(i) >> d.at(i);
  }
  int max_l = 0, max_r = 0;
  int st_n = 0;
  int count = 0;
  for (int i = q - 1; i >= 0; --i) {
    if (t.at(i) == s.at(st_n) && d.at(i) == 'L') {
      count++;
      st_n++;
    }
    if (st_n != 0) {
      if (t.at(i) == s.at(st_n - 1) && d.at(i) == 'R') {
        max_l = max(count - 1, max_l);
        count = 0;
        st_n = 0;
      }
    }
  }
  max_l = max(count, max_l);
  count = 0;
  st_n = n - 1;
  for (int i = q - 1; i >= 0; --i) {
    if (t.at(i) == s.at(st_n) && d.at(i) == 'R') {
      count++;
      st_n--;
    }
    if (st_n != n - 1) {
      if (t.at(i) == s.at(st_n + 1) && d.at(i) == 'L') {
        max_r = max(count - 1, max_r);
        count = 0;
        st_n = n - 1;
      }
    }
  }
  max_r = max(count, max_r);
  if (n - max_l - max_r > 0) {
    cout << n - max_l - max_r << endl;
  } else {
    cout << 0 << endl;
  }
}
