#include <bits/stdc++.h>
using namespace std;
const int vx[4] = {0, 1, 0, -1};
const int vy[4] = {1, 0, -1, 0};
void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int n, q;
string s;
vector<char> t, d;
bool g(int m) {
  m--;
  for (int i = (int)0; i < (int)q; i++) {
    if (s[m] == t[i]) {
      if (d[i] == 'L')
        m--;
      else
        m++;
    }
    if (m < 0 || m > n) return true;
  }
  return false;
}
int f() {
  int l = 0, r = n - 1;
  while (r - l > 1) {
    int m = (r + l) / 2;
    if (g(m))
      l = m;
    else
      r = m;
  }
  if (g(r)) return r;
  return l;
}
int main() {
  cin >> n >> q;
  cin >> s;
  for (int i = (int)0; i < (int)q; i++) {
    char a, b;
    cin >> a >> b;
    t.push_back(a);
    d.push_back(b);
  }
  int l = f();
  reverse(s.begin(), s.end());
  for (int i = (int)0; i < (int)q; i++) {
    if (d[i] == 'L')
      d[i] = 'R';
    else
      d[i] = 'L';
  }
  int r = f();
  cout << min(n, n - l - r) << endl;
}
