#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  struct Info {
    char c;
    char d;
    ll ofs = 0;
  };
  vector<Info> tdq(Q);
  for (auto &&tq : tdq) {
    cin >> tq.c >> tq.d;
    tq.ofs = tq.d == 'L' ? -1 : 1;
  }
  auto check_t = [&](ll v, ll pos) {
    for (const auto &tq : tdq) {
      auto c = s.at(v);
      if (c == tq.c) v += tq.ofs;
      if (v == pos) return true;
      if (v < 0 || v >= s.size()) break;
    }
    return false;
  };
  auto check_func = [&](ll pos, bool is_flag) {
    ll lb = 0, ub = s.size();
    while (ub - lb > 1) {
      ll mid = (lb + ub) / 2;
      if (check_t(mid, pos) == is_flag) {
        ub = mid;
      } else {
        lb = mid;
      };
    }
    return ub;
  };
  ll r = check_func(s.size(), true) - 1;
  ;
  ll l = check_func(-1, false);
  ;
  assert(r >= l);
  cout << r - l + 1 << endl;
  return 0;
}
int main_() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<ll> num(N, 1);
  unordered_map<char, vector<ll>> c_pos;
  for (ll i = (0); i < (s.size()); ++i) {
    auto c = s[i];
    c_pos[c].push_back(i);
  }
  for (ll i = (0); i < (Q); ++i) {
    char t, d;
    cin >> t >> d;
    ll ofs = d == 'L' ? -1 : 1;
    for (auto &pos : c_pos[t]) {
      if (pos + ofs >= 0 && pos + ofs < num.size()) num[pos + ofs] += num[pos];
      num[pos] = 0;
    }
  }
  ll ans = accumulate(num.begin(), num.end(), 0LL);
  cout << ans << endl;
  return 0;
}
