#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
ll n, q;
string s;
vector<char> t, d;
bool isOkL(ll mid) {
  ll pos = mid;
  for (int i = (int)(0); i < (int)(q); ++i) {
    if (s[pos] == t[i]) {
      if (d[i] == 'L') {
        pos--;
        if (pos < 0) return true;
      } else {
        pos++;
      }
    }
  }
  return false;
}
bool isOkR(ll mid) {
  ll pos = mid;
  for (int i = (int)(0); i < (int)(q); ++i) {
    if (s[pos] == t[i]) {
      if (d[i] == 'R') {
        pos++;
        if (pos >= n) return true;
      } else {
        pos--;
      }
    }
  }
  return false;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q >> s;
  t.resize(n), d.resize(n);
  for (int i = (int)(0); i < (int)(q); ++i) cin >> t[i] >> d[i];
  ll ans = 0;
  ll ok = -1, ng = n + 1;
  while (abs(ok - ng) > 1) {
    ll m = (ok + ng) / 2;
    if (isOkL(m))
      ok = m;
    else
      ng = m;
  }
  ans = ok + 1;
  ok = n, ng = -1;
  while (abs(ok - ng) > 1) {
    ll m = (ok + ng) / 2;
    if (isOkR(m))
      ok = m;
    else
      ng = m;
  }
  ans += n - ok;
  ans = n - ans;
  chmin(ans, n);
  cout << ans << endl;
}
