#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, char>> t(q);
  for (int i = 0; i < q; i++) {
    char a, b;
    cin >> a >> b;
    t[i] = make_pair(a, b);
  }
  int l = 0, r = n - 1;
  for (int i = q - 1; i >= 0; i--) {
    if (l < n - 1 && t[i].first == s[l] && t[i].second == 'L') {
      l++;
    } else if (l > 0 && t[i].first == s[l - 1] && t[i].second == 'R') {
      l--;
    }
    if (r > 0 && t[i].first == s[r] && t[i].second == 'R') {
      r--;
    } else if (r < n - 1 && t[i].first == s[r + 1] && t[i].second == 'L') {
      r++;
    }
  }
  cout << max(0, n - l - (n - 1 - r)) << endl;
  return 0;
}
