#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int q;
  unordered_map<char, vector<int>> um;
  cin >> n >> q;
  int cnt[n];
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    um[c].push_back(i);
    cnt[i] = 1;
  }
  for (int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    for (int j = 0; j < um[t].size(); j++) {
      int pos = um[t][j];
      if (d == 'L' && pos != 0) {
        cnt[pos - 1] += cnt[pos];
      } else if (d == 'R' && pos != n - 1) {
        cnt[pos + 1] += cnt[pos];
      }
      cnt[pos] = 0;
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    res += cnt[i];
  }
  cout << res;
  return 0;
}
