#include <bits/stdc++.h>
using namespace std;
long long int n, q;
string s;
bool calc(long long int pos, vector<pair<char, char>> *v, bool dir) {
  long long int goal;
  long long int now = pos;
  if (dir == 0)
    goal = -1;
  else
    goal = n;
  for (long long int i = 0; i < q; i++) {
    if (now < 0 || now >= n) break;
    if (v->at(i).first == s[now]) {
      if (v->at(i).second == 'L')
        now--;
      else
        now++;
    }
  }
  if (now == goal)
    return true;
  else
    return false;
}
long long int func(vector<pair<char, char>> *v) {
  long long int high = n;
  long long int low = -1;
  long long int middle;
  while (high - low > 1) {
    middle = (low + high) / 2;
    if (calc(middle, v, 0)) {
      low = middle;
    } else
      high = middle - 1;
  }
  long long int left = high;
  high = n;
  low = -1;
  while (high - low > 1) {
    middle = (low + high) / 2;
    if (calc(middle, v, 1)) {
      high = middle;
    } else
      low = middle + 1;
  }
  long long int right = low;
  if (0) cout << "left=" << left << " right=" << right << endl;
  return right - left - 1;
}
signed main() {
  cin >> n >> q;
  cin >> s;
  vector<pair<char, char>> v;
  for (long long int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    v.push_back(make_pair(t, d));
  }
  cout << func(&v) << endl;
  return 0;
}
