#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

long long n, q;
string s;
vector<pair<char, char>> v;

long long solve();

int main() {
  cin >> n >> q;
  cin >> s;
  v.resize(q);
  for(int i = 0; i < q; ++i)
    cin >> v[q - 1 - i].fi >> v[q - 1 - i].se;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long l = 0, r = n - 1;
  for(int i = 0; i < q; ++i) {
    if(l < n && v[i].fi == s[l] && v[i].se == 'L') ++l;
    if(r >= 0 && v[i].fi == s[r] && v[i].se == 'R') --r;
    if(l > 0 && s[l - 1] == v[i].fi && v[i].se == 'R') --l;
    if(r < n - 1 && s[r + 1] == v[i].fi && v[i].se == 'L')
      ++r;
  }
  return max(0LL, r - l + 1);
}