#include <bits/stdc++.h>
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].first >> v[q - 1 - i].second;
  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].first == s[l] && v[i].second == 'L') ++l;
    if (r >= 0 && v[i].first == s[r] && v[i].second == 'R') --r;
  }
  return max(0LL, r - l + 1);
}
