#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e16;
const long long MAX_N = 100010;
int main() {
  long long n, q;
  string s;
  cin >> n >> q >> s;
  vector<char> t(q), d(q);
  for (long long i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  long long left1 = -1;
  long long right1 = n;
  while (left1 - right1 > 1) {
    long long x = (left1 + right1) / 2;
    long long p = x;
    bool ok = true;
    for (long long i = 0; i < q; i++) {
      if (s[p] == t[i]) {
        if (d[i] == 'R') {
          p++;
        } else {
          p--;
        }
      }
      if (p < 0) {
        ok = false;
        break;
      } else if (n <= p) {
        break;
      }
    }
    if (ok) {
      left1 = x;
    } else {
      right1 = x;
    }
  }
  long long left2 = -1;
  long long right2 = n;
  while (left2 - right2 > 1) {
    long long x = (left2 + right2) / 2;
    long long p = x;
    bool ok = true;
    for (long long i = 0; i < q; i++) {
      if (s[p] == t[i]) {
        if (d[i] == 'R') {
          p++;
        } else {
          p--;
        }
      }
      if (p >= n) {
        ok = false;
        break;
      } else if (p < 0) {
        break;
      }
    }
    if (ok) {
      left2 = x;
    } else {
      right2 = x;
    }
  }
  cout << max(0LL, right2 - right1 + 1) << endl;
  return 0;
}
