#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC target("avx")
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using namespace std;
bool will_be_in(int i, int n, int q, string &s, vector<char> &t,
                vector<char> &d) {
  for (unsigned long long i = 0, i_len = (q); i < i_len; i++) {
    if (s[i] == t[i]) {
      if (d[i] == 'L')
        i--;
      else
        i++;
      if (i < 0 || n <= i) return false;
    }
  }
  return true;
}
int find_one(int i, int n, int q, string &s, vector<char> &t, vector<char> &d) {
}
int main() {
  ll n, q;
  string s;
  cin >> n >> q >> s;
  vector<char> t(q), d(q);
  for (unsigned long long i = 0, i_len = (q); i < i_len; i++) {
    cin >> t[i] >> d[i];
  }
  int rend = n;
  int lend = -1;
  for (int i = q; i--;) {
    if (d[i] == 'L') {
      if (t[i] == s[lend + 1]) {
        lend++;
      }
    } else {
      if (t[i] == s[rend - 1]) {
        rend--;
      }
    }
    if (lend >= n - 1 || rend <= 0) break;
  }
  cout << max(0, rend - lend - 1) << endl;
}
