#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<char, char>;
constexpr ll INF = 1LL << 62;
ll N, Q;
string S;
vector<p> query;
bool solve(ll g) {
  for (auto q : query) {
    if (S[g] == q.first) {
      if (q.second == 'L') {
        g--;
      } else {
        g++;
      }
      if (g < 0 || g >= N) {
        return true;
      }
    }
  }
  return false;
}
int main(void) {
  cin >> N >> Q;
  cin >> S;
  for (ll i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    query.push_back(p(t, d));
  }
  ll ok = N - 1;
  ll ng = 0;
  while (abs(ok - ng) > 1) {
    ll c = (ok + ng) / 2;
    if (solve(c)) {
      ok = c;
    } else {
      ng = c;
    }
  }
  ll right = ok;
  ok = 0;
  ng = N - 1;
  while (abs(ok - ng) > 1) {
    ll c = (ok + ng) / 2;
    if (solve(c)) {
      ok = c;
    } else {
      ng = c;
    }
  }
  ll left = ok;
  cout << (right - left - 1) << endl;
  return 0;
}
