#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long n, q, lar[30], sma[30];
string s;
bool jud;
vector<pair<char, char> > vec;
long long pow(long long x, long long y) {
  if (y == 0) return 1;
  if (y % 2) {
    return pow(x, y - 1) * x % mod;
  } else {
    long long yyy = pow(x, y / 2);
    return yyy * yyy % mod;
  }
}
long long div(long long x) { return pow(x, mod - 2); }
int main(void) {
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    vec.push_back(pair<char, char>(t, d));
  }
  long long po = -1, ansn = -1;
  for (int i = vec.size() - 1; i >= 0; i--) {
    if (s[po + 1] == vec[i].first && vec[i].second == 'L') {
      po++;
    } else if (po > 0) {
      if (s[po - 1] == vec[i].first && vec[i].second == 'R') {
        po--;
      }
    }
    if (po == n) {
      jud = true;
      break;
    }
    ansn = max(ansn, po);
  }
  long long qo = n, ansx = n;
  for (int i = vec.size() - 1; i >= 0; i--) {
    if (s[qo - 1] == vec[i].first && vec[i].second == 'R') {
      qo--;
    } else if (qo < n - 1) {
      if (s[qo + 1] == vec[i].first && vec[i].second == 'L') {
        qo++;
      }
    }
    if (qo == 0) {
      jud = true;
      break;
    }
    ansx = min(ansx, qo);
  }
  if (jud) {
    cout << 0 << endl;
  } else {
    if (ansx > ansn) {
      cout << ansx - 1 - ansn << endl;
    } else {
      cout << 0 << endl;
    }
  }
  int www;
  cin >> www;
}
