#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<pair<long long, long long>> v;
  for (long long i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    long long tt, dd;
    if (d == 'R')
      dd = 0;
    else
      dd = 1;
    tt = t - 'A';
    v.push_back({tt, dd});
  }
  long long nowd = 0;
  while (1) {
    long long l = nowd;
    long long stat = 0;
    for (long long i = 0; i < q; i++) {
      if (v[i].first == s[l] - 'A') {
        if (v[i].second == 0)
          l++;
        else
          l--;
      }
      if (l >= n) {
        cout << 0 << endl;
        return 0;
      }
      if (l < 0) {
        stat = 1;
        break;
      }
    }
    if (stat == 0) {
      break;
    }
    nowd++;
    if (nowd >= n) {
      cout << 0 << endl;
      return 0;
    }
  }
  long long ansr = nowd;
  nowd = n - 1;
  while (1) {
    long long l = nowd;
    long long stat = 0;
    for (long long i = 0; i < q; i++) {
      if (v[i].first == s[l] - 'A') {
        if (v[i].second == 0)
          l++;
        else
          l--;
      }
      if (l < 0) {
        cout << 0 << endl;
        return 0;
      }
      if (l >= n) {
        stat = 1;
        break;
      }
    }
    if (stat == 0) {
      break;
    }
    nowd--;
    if (nowd < 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << nowd - ansr + 1 << endl;
  return 0;
}
