#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;
class RollingHash {
 private:
  using ULL = unsigned long long;
  int n;
  const ULL mod = 1ULL << 63;
  const ULL base = 1000000007ULL;
  vector<ULL> hash, power;

 public:
  RollingHash(string s) {
    n = s.size();
    hash.assign(n + 1, 0ULL);
    power.assign(n + 1, 0ULL);
    power[0] = 1ULL;
    for (int i = 0; i < n; i++) {
      power[i + 1] = power[i] * base % mod;
      hash[i + 1] = (s[i] + hash[i] * base) % mod;
    }
  }
  ULL GetHash(int l, int r) {
    return ((hash[r] - hash[l] * power[r - l]) % mod + mod) % mod;
  }
};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> t(q), d(q);
  for (int i = (int)(0); i < (int)(q); ++i) cin >> t[i] >> d[i];
  auto f = [&](int m, int num) {
    for (int i = (int)(0); i < (int)(q); ++i) {
      if (t[i] == s[m]) {
        m += (d[i] == 'L' ? -1 : 1);
        cout << t[i] << " " << m << endl;
      }
      if (m == num)
        return true;
      else if (m >= n)
        return false;
      else if (m < 0)
        return false;
    }
    return false;
  };
  int r, l;
  int ok = 0, ng = n + 1;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (f(mid - 1, -1))
      ok = mid;
    else
      ng = mid;
  }
  l = ok;
  ok = 0, ng = n + 1;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (f(n - mid, n))
      ok = mid;
    else
      ng = mid;
  }
  r = ok;
  cout << max(0, n - l - r) << endl;
}
