#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long n, q;
string s;
vector<char> t, d;
bool simulate(long long idx) {
  for (long long i = 0; i < (q); ++i) {
    if (t[i] == s[idx]) {
      if (d[i] == 'L') {
        idx--;
      } else
        idx++;
    }
    if (idx == 0 || idx == n + 1) return true;
  }
  return false;
}
signed main() {
  cin >> n >> q >> s;
  s = " " + s;
  for (long long i = 0; i < (q); ++i) {
    char T, D;
    cin >> T >> D;
    t.push_back(T);
    d.push_back(D);
  }
  long long left = 0, right = n + 1;
  while (right - left != 1) {
    long long mid = (left + right) / 2;
    bool falled;
    falled = simulate(mid);
    if (falled)
      left = mid;
    else
      right = mid;
  }
  long long L = right;
  left = 0, right = n + 1;
  while (right - left != 1) {
    long long mid = (left + right) / 2;
    bool falled;
    falled = simulate(mid);
    if (falled)
      right = mid;
    else
      left = mid;
  }
  long long R = left;
  cout << (R - L + 1) << endl;
  ;
  return 0;
}
