#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const long long INFL = (1L << 62);
int N, Q;
string s;
vector<char> t, d;
int main() {
  int ans = 0;
  cin >> N >> Q >> s;
  t.resize(N);
  d.resize(N);
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  s = "_" + s + "_";
  int l = 0, r = N + 1;
  while (l < r - 1) {
    int mid = (l + r) / 2;
    int pos = mid;
    bool exist = true;
    for (int i = 0; i < Q; i++) {
      if (s[pos] == t[i]) {
        if (d[i] == 'L')
          pos--;
        else
          pos++;
      }
      if (pos == 0) {
        exist = false;
        break;
      } else if (pos == N + 1) {
        break;
      }
    }
    if (exist)
      r = mid;
    else
      l = mid;
  }
  ans -= r;
  l = 0, r = N + 1;
  while (l < r - 1) {
    int mid = (l + r) / 2;
    int pos = mid;
    bool exist = true;
    for (int i = 0; i < Q; i++) {
      if (s[pos] == t[i]) {
        if (d[i] == 'L')
          pos--;
        else
          pos++;
      }
      if (pos == N + 1) {
        exist = false;
        break;
      } else if (pos == 0) {
        break;
      }
    }
    if (exist)
      l = mid;
    else
      r = mid;
  }
  ans += l;
  ans = max(0, ans + 1);
  cout << ans << endl;
  return 0;
}
