#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int inf_int = 1e9 + 100;
const long long inf_ll = 8e18;
const double pi = 3.1415926535898;
bool debug = 0;
const int MAXN = (4e5) + 100;
const int LOG = 21;
const int mod = 1e9 + 7;
const int MX = (2e7 + 10);
char s[MAXN];
char t[MAXN], d[MAXN];
void solve() {
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
  }
  for (int i = 1; i <= q; ++i) {
    cin >> t[i] >> d[i];
  }
  int l = 1, r = n;
  int ans = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    int v = mid;
    for (int i = 1; i <= q; ++i) {
      if (t[i] == s[v]) {
        if (d[i] == 'L') {
          v--;
        } else {
          v++;
        }
      }
      if (v == 0) break;
      if (v == n + 1) break;
    }
    42;
    if (v == 0) {
      ans = mid;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  l = 1, r = n;
  int ans2 = -1;
  42;
  while (l <= r) {
    int mid = (l + r) >> 1;
    int v = mid;
    for (int i = 1; i <= q; ++i) {
      if (t[i] == s[v]) {
        if (d[i] == 'L') {
          v--;
        } else {
          v++;
        }
      }
      if (v == 0) break;
      if (v == n + 1) break;
    }
    42;
    if (v == n + 1) {
      ans2 = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  42;
  42;
  if (ans == -1 && ans2 == -1) {
    cout << n << "\n";
    return;
  }
  if (ans == -1 && ans2 != -1) {
    cout << ans2 - 1 << "\n";
    return;
  }
  if (ans2 == -1) {
    cout << n - ans << "\n";
    return;
  }
  if (ans2 <= ans) {
    cout << 0 << "\n";
  } else {
    cout << n - (ans + n - ans2 + 1) << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.precision(15);
  int t = 1;
  while (t--) {
    solve();
  }
  42;
}
