#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T>
T binarySearchFunction(int begin, int end, function<bool(T index)> func) {
  T lb = begin - 1, ub = end - 1;
  while (lb < ub - 1) {
    T mid = (lb + ub) / 2;
    if (func(mid))
      lb = mid;
    else
      ub = mid;
  }
  if (ub == end - 1 && func(ub)) return end;
  return ub;
}
template <typename T>
T df(int begin, int end, function<bool(T index)> func) {
  if (begin == end) return -1;
  int mid = (begin + end) / 2;
  if (!func(mid)) return mid;
  if (begin == end - 1) return -1;
  T lb = df(0, mid, func);
  if (lb >= 0) return lb;
  T rb = df(mid, end, func);
  if (rb >= 0) return rb;
  return -1;
}
int main() {
  ll n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, bool>> v(q);
  for (size_t i = 0; i < (q); ++i) {
    char a, b;
    cin >> a >> b;
    v[i] = pair<char, bool>(a, b == 'R');
  }
  auto is = [n, q, v, s](int idx) -> bool {
    for (size_t i = 0; i < (q); ++i) {
      if (s[idx] == v[i].first) {
        idx += v[i].second ? 1 : -1;
        if (idx == -1 || idx == n) return true;
      }
    }
    return false;
  };
  auto isn = [is](int idx) { return !is(idx); };
  ll mid = df<ll>(0, n, is);
  if (mid == -1)
    cout << 0 << endl;
  else {
    ll ans = 0;
    ans += binarySearchFunction<ll>(0, mid + 1, is);
    ans += n - binarySearchFunction<ll>(mid, n, isn);
    cout << n - ans << endl;
  }
  return 0;
}
