#include <bits/stdc++.h>
using namespace std;
vector<long long> dp[200000];
vector<pair<long long, long long>> v;
string s;
long long n, q;
long long rets(long long nowd) {
  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) {
      return 1;
    }
    if (l < 0) {
      return 2;
    }
  }
  return 0;
}
signed main() {
  cin >> n >> q;
  cin >> s;
  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 l = 0, r = n - 1, m;
  for (long long i = 0; i < 30; i++) {
    m = 0.5 + (double)(r + l) / 2;
    if (rets(m) == 2)
      l = m;
    else
      r = m;
  }
  long long lmi = r;
  l = 0, r = n - 1;
  for (long long i = 0; i < 30; i++) {
    m = 0.5 + (double)(r + l) / 2;
    if (rets(m) == 1)
      r = m;
    else
      l = m;
  }
  long long rmi = l;
  cout << rmi - lmi + 1 << endl;
  return 0;
}
