#include <bits/stdc++.h>
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<int> num_(n, 1);
  vector<char> str_;
  char s[n];
  cin >> s;
  for (int i = 0; i < n; i++) {
    str_.push_back(s[i]);
  }
  char tmp, tmpp;
  for (int i = 0; i < q; i++) {
    cin >> tmp >> tmpp;
    for (int l = 0; l < n; l++) {
      if (str_[l] == tmp) {
        if (tmpp == 'L') {
          if (num_[l] > 0) {
            if (l != 0) {
              num_[l - 1] += num_[l];
            }
            num_[l] = 0;
          }
        } else {
          if (num_[l] > 0) {
            if (l + 1 != n - 1) {
              num_[l + 1] += num_[l];
            }
            num_[l] = 0;
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (num_[i] > 0) {
      ans += num_[i];
    }
  }
  cout << ans;
  return 0;
}
