#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
void d_err() { cerr << endl; }
template <typename H, typename... T>
void d_err(H h, T... t) {
  cerr << h << " ";
  d_err(t...);
}
template <typename T>
void print(T x) {
  cout << x << "\n";
}
long long INF = 1e16;
int inf = 1e9;
long long MOD = 1e9 + 7;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> l(q), d(q);
  for (int i = (0); i < (q); ++i) cin >> l[i] >> d[i];
  int ok = -1, ng = s.size();
  while (ng - ok > 1) {
    int mid = (ng + ok) / 2;
    int cur = mid;
    for (int i = (0); i < (q); ++i) {
      if (s[cur] != l[i]) continue;
      if (d[i] == 'L')
        cur--;
      else
        cur++;
      if (cur == -1 || cur == s.size()) break;
    }
    if (cur == -1)
      ok = mid;
    else
      ng = mid;
  }
  long long ans = ok + 1;
  83;
  ok = s.size(), ng = 0;
  while (ok - ng > 1) {
    int mid = (ng + ok) / 2;
    83;
    int cur = mid;
    for (int i = (0); i < (q); ++i) {
      if (s[cur] != l[i]) continue;
      if (d[i] == 'L')
        cur--;
      else
        cur++;
      if (cur == -1 || cur == s.size()) break;
    }
    if (cur == s.size())
      ok = mid;
    else
      ng = mid;
  }
  ans += n - ok;
  83;
  print(n - ans);
}
