#include <bits/stdc++.h>
using llong = long long;
int main() {
  int N;
  int Q;
  std::cin >> N >> Q;
  assert(1 <= N and N <= 2 * 1.0e+5);
  assert(1 <= Q and Q <= 2 * 1.0e+5);
  std::string s;
  std::cin >> s;
  s.insert(s.begin(), '-');
  assert(static_cast<int>(s.length()) == 1 + N);
  std::vector<char> t(1 + Q);
  std::vector<char> d(1 + Q);
  for (int i = 1; i <= Q; ++i) {
    std::cin >> t[i] >> d[i];
    assert(d[i] == 'L' or d[i] == 'R');
  }
  std::map<char, std::vector<int>> indexList;
  for (int j = 1; j <= N; ++j) {
    indexList[s[j]].push_back(j);
  }
  std::vector<llong> res(1 + N, 1LL);
  for (int i = 1; i <= Q; ++i) {
    char t_ = t[i];
    char d_ = d[i];
    for (int j : indexList[t_]) {
      assert(1 <= j and j <= N);
      if (d_ == 'L') {
        if (j == 1) {
          res[j] = 0;
        } else {
          res[j - 1] += res[j];
          res[j] = 0;
        }
      } else {
        assert(d_ == 'R');
        if (j == N) {
          res[N] = 0;
        } else {
          res[j + 1] += res[j];
          res[j] = 0;
        }
      }
    }
  }
  llong val = 0LL;
  for (int j = 1; j <= N; ++j) {
    val += res[j];
  }
  std::cout << val << std::endl;
  return 0;
}
