#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (const auto &v : vec) {
    os << v << ",";
  }
  os << "]";
  return os;
}
template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T, size_t size>
void fill(T (&ary)[size], const T &val) {
  fill_n((T *)ary, size, val);
}
void solve() {
  i64 N, Q;
  string s;
  cin >> N >> Q >> s;
  vector<map<i64, i64>> color(26);
  for (i64 i = i64(0), i_max_for_repmacro = i64(N); i < i_max_for_repmacro;
       ++i) {
    color[s[i] - 'A'][i]++;
  }
  vector<char> t(Q), d(Q);
  vector<vector<pair<i64, char>>> query(26);
  for (i64 i = i64(0), i_max_for_repmacro = i64(Q); i < i_max_for_repmacro;
       ++i) {
    cin >> t[i] >> d[i];
    query[t[i] - 'A'].emplace_back(make_pair(i, d[i]));
  }
  vector<unordered_map<i64, bool>> memo(N);
  vector<unordered_map<i64, bool>> done(N);
  function<bool(i64, i64)> rec = [&](i64 i, i64 j) {
    if (i < 0 or N <= i) return false;
    if (j >= Q) return true;
    auto &res = memo[i][j];
    if (done[i][j]) return res;
    done[i][j] = true;
    i64 rem = Q - j;
    if (0 <= i - rem and i + rem < N) return res = true;
    auto it = lower_bound(begin(query[s[i] - 'A']), end(query[s[i] - 'A']),
                          make_pair(j, char(0)));
    if (it == query[s[i] - 'A'].end()) {
      return res = true;
    }
    i64 nj = it->first;
    char dist = it->second;
    if (j == nj) return res = rec(i + (dist == 'L' ? -1 : 1), nj + 1);
    return res = rec(i, nj);
  };
  i64 ans = 0;
  for (i64 i = i64(0), i_max_for_repmacro = i64(N); i < i_max_for_repmacro;
       ++i) {
    if (rec(i, 0)) ++ans;
  }
  cout << ans << endl;
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}
