#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  vector<char> t_vec;
  vector<char> d_vec;
  t_vec.reserve(Q);
  d_vec.reserve(Q);
  char t, d;
  for (size_t i = 0; i < Q; i++) {
    cin >> t >> d;
    t_vec.push_back(t);
    d_vec.push_back(d);
  }
  map<char, vector<int>> toID;
  for (size_t i = 0; i < s.length(); i++) {
    toID[s[i]].push_back(i);
  }
  vector<int> data(N, 1);
  int ret = 0;
  for (size_t i = 0; i < Q; i++) {
    if (toID.find(t_vec[i]) == toID.end()) continue;
    vector<int> pos = toID[t_vec[i]];
    vector<int> new_data(N, 0);
    for (auto &it : pos) {
      new_data[it] = data[it];
      data[it] = 0;
    }
    for (auto &it : pos) {
      if (d_vec[i] == 'R') {
        if (it < N - 1) {
          data[it + 1] += new_data[it];
        } else {
          ret += new_data[it];
        }
      } else if (d_vec[i] == 'L') {
        if (it > 0) {
          data[it - 1] += new_data[it];
        } else {
          ret += new_data[it];
        }
      }
    }
  }
  cout << (N - ret);
}
