#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<pair<char, bool>> td(Q);
  for (long long i = 0; i < Q; ++i) {
    char t;
    char d;
    cin >> t >> d;
    td[i].first = t;
    td[i].second = (d == 'L');
  }
  map<char, vector<long long>> c2pos;
  for (long long i = 0; i < s.size(); ++i) {
    c2pos[s[i]].push_back(i);
  }
  vector<long long> g(N, 1);
  for (long long i = 0; i < Q; ++i) {
    const auto& poslist = c2pos[td[i].first];
    if (td[i].second) {
      for (const auto e : poslist) {
        if (e != 0) g[e - 1] += g[e];
        g[e] = 0;
      }
    } else {
      for (const auto e : poslist) {
        if (e != N - 1) g[e + 1] += g[e];
        g[e] = 0;
      }
    }
  }
  long long ans = 0;
  for (const auto e : g) {
    ans += e;
  }
  cout << ans << endl;
}
