#include <bits/stdc++.h>
using namespace std;
const int64_t INF = 100000000;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q), d(Q);
  for (int64_t i = 0; i < Q; i++) {
    cin >> t.at(i) >> d.at(i);
  }
  vector<int64_t> cont(N);
  for (int64_t j = 0; j < N; j++) {
    cont.at(j) = 1;
  }
  for (int64_t i = 0; i < Q; i++) {
    for (int64_t j = 0; j < N; j++) {
      if (s.at(j) == t.at(i) && d.at(i) == 'L') {
        if (j == 0)
          cont.at(j) = 0;
        else {
          cont.at(j - 1) = cont.at(j - 1) + cont.at(j);
          cont.at(j) = 0;
        }
      } else if (s.at(j) == t.at(i) && d.at(i) == 'R') {
        if (j == N - 1)
          cont.at(j) = 0;
        else {
          cont.at(j + 1) = cont.at(j + 1) + cont.at(j);
          cont.at(j) = 0;
        }
      }
    }
  }
  int64_t all = 0;
  for (int64_t j = 0; j < N; j++) {
    all = all + cont.at(j);
  }
  cout << all << endl;
}
