#include <bits/stdc++.h>
int main() {
  uint32_t N, Q;
  std::string s;
  std::vector<std::pair<char, char>> td;
  std::cin >> N >> Q;
  std::cin >> s;
  for (auto i = 0u; i < Q; ++i) {
    std::string t, d;
    std::cin >> t >> d;
    td.push_back(std::make_pair(t[0], d[0]));
  }
  std::vector<uint32_t> C;
  C.resize(N, 1);
  std::unordered_map<char, std::set<uint32_t>*> M;
  for (uint32_t i = 0; i < s.size(); ++i) {
    auto m = M.find(s[i]);
    if (m != M.end()) {
      m->second->insert(i);
    } else {
      auto p = new std::set<uint32_t>();
      p->insert(i);
      M.insert(std::make_pair(s[i], p));
    }
  }
  for (auto it = td.begin(); it != td.end(); it++) {
    int shift = (it->second == 'R' ? 1 : -1);
    auto m = M.find(it->first);
    if (m == M.end()) continue;
    std::vector<uint32_t> removes;
    if (shift == 1) {
      for (auto it2 = m->second->rbegin(); it2 != m->second->rend(); it2++) {
        auto i = *it2;
        int new_i = i + shift;
        if (new_i >= 0 && new_i < s.size()) {
          C[new_i] += C[i];
          M[s[new_i]]->insert(new_i);
        }
        C[i] = 0;
        removes.push_back(i);
      }
    } else {
      for (auto it2 = m->second->begin(); it2 != m->second->end(); it2++) {
        auto i = *it2;
        int new_i = i + shift;
        if (new_i >= 0 && new_i < s.size()) {
          C[new_i] += C[i];
          M[s[new_i]]->insert(new_i);
        }
        C[i] = 0;
        removes.push_back(i);
      }
    }
    for (auto it = removes.begin(); it != removes.end(); it++) {
      m->second->erase(m->second->find(*it));
    }
  }
  uint32_t ret = 0;
  for (auto it = C.begin(); it != C.end(); it++) ret += *it;
  std::cout << ret << std::endl;
}
