#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() {
  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.at(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;
}
