#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<char> t(q), d(q);
  for (int i = 0; i < q; i++) {
    cin >> t.at(i) >> d.at(i);
  }
  int left = -1;
  int right = s.size();
  int golem_index;
  bool flag = false;
  while (right - left > 1) {
    flag = false;
    int mid = left + (right - left) / 2;
    golem_index = mid;
    for (int i = 0; i < q; i++) {
      if (s.at(golem_index) == t.at(i)) {
        if (d.at(i) == 'L')
          golem_index--;
        else
          golem_index++;
      }
      if (golem_index == -1) {
        flag = true;
        break;
      }
    }
    if (flag)
      left = mid;
    else
      right = mid;
  }
  int left_golem = right;
  left = -1;
  right = (int)s.size();
  while (right - left > 1) {
    flag = false;
    int mid = left + (right - left) / 2;
    golem_index = mid;
    for (int i = 0; i < q; i++) {
      if (s.at(golem_index) == t.at(i)) {
        if (d.at(i) == 'L')
          golem_index--;
        else
          golem_index++;
      }
      if (golem_index == (int)s.size()) {
        flag = true;
        break;
      }
    }
    if (flag)
      right = mid;
    else
      left = mid;
  }
  int right_golem = left;
  int ans = right_golem - left_golem + 1;
  cout << ans << endl;
}
