#include <bits/stdc++.h>
using namespace std;
int n, q;
bool isRange(int a) { return 0 <= a && a < n; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  string s;
  cin >> s;
  vector<pair<char, char>> td;
  int t, d;
  for (int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    td.push_back(make_pair(t, d));
  }
  int l = -1;
  int r = n;
  for (int i = td.size() - 1; i >= 0; i--) {
    char t = td[i].first, d = td[i].second;
    if (isRange(l + 1) && s[l + 1] == t && d == 'L') {
      l++;
    }
    if (isRange(r - 1) && s[r - 1] == t && d == 'R') {
      r--;
    }
  }
  cout << n - (l + 1) - (n - r) << endl;
  return 0;
}
