#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  ios::sync_with_stdio(false);
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<pair<char, char>> qs = vector<pair<char, char>>(q);
  for (long long i = 0; i < (long long)q; ++i) {
    char t, d;
    cin >> t >> d;
    qs[i] = pair<char, char>(t, d);
  }
  reverse(qs.begin(), qs.end());
  long long l = 0, r = n - 1;
  for (long long i = 0; i < (long long)q; ++i) {
    char t, d;
    t = qs[i].first;
    d = qs[i].second;
    if (l < n && s[l] == t && d == 'L') {
      l++;
    }
    if (0 <= r && s[r] == t && d == 'R') {
      r--;
    }
  }
  cout << ((((r - l + 1)) > (0)) ? ((r - l + 1)) : (0)) << "\n";
  return 0;
}
