#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  vector<char> s(N), t(Q), d(Q);
  vector<vector<int>> vec(26, vector<int>(0, {}));
  string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  vector<int> gore(N, 1);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  for (int i = 0; i < Q; i++) {
    cin >> t.at(i) >> d.at(i);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 26; j++) {
      if (s.at(i) == alpha.at(j)) {
        vec.at(j).push_back(i);
      }
    }
  }
  for (int i = 0; i < Q; i++) {
    vector<int> tempgore(N, 0);
    int k = 0;
    for (int j = 0; j < 26; j++) {
      if (t.at(i) == alpha.at(j)) {
        k = j;
      }
    }
    int masusuu = vec.at(k).size();
    if (masusuu == 0) {
      continue;
    }
    for (int j = 0; j < masusuu; j++) {
      int p = vec.at(k).at(j);
      int q;
      if (d.at(i) == 'L') {
        q = -1;
      } else {
        q = 1;
      }
      if (p == 0 && q == -1) {
        gore.at(p) = 0;
        continue;
      }
      if (p == N - 1 && q == 1) {
        gore.at(p) = 0;
        continue;
      }
      int place = p + q;
      tempgore.at(place) = gore.at(p);
      gore.at(p) = 0;
    }
    for (int j = 0; j < N; j++) {
      gore.at(j) += tempgore.at(j);
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += gore.at(i);
  }
  cout << ans << endl;
}
