#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  pair<char, char> p[200010];
  for (int i = 0; i < q; i++) {
    cin >> p[i].first >> p[i].second;
  }
  int die[200010] = {};
  int l = -1, r = n;
  for (int i = q - 1; i >= 0; i--) {
    if (p[i].second == 'L') {
      if (l + 1 < n && s[l + 1] == p[i].first) {
        l++;
        die[l] = 1;
      }
      if (r + 1 < n && s[r + 1] == p[i].first) {
        r++;
        die[r] = 1;
      }
    } else {
      if (l - 1 >= 0 && s[l - 1] == p[i].first) {
        l--;
        die[l] = 1;
      }
      if (r - 1 >= 0 && s[r - 1] == p[i].first) {
        r--;
        die[r] = 1;
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cnt += die[i];
  }
  cout << n - cnt << endl;
  return 0;
}
