#include <bits/stdc++.h>
using namespace std;
void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}
using ll = long long;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;
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;
}
void _main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q), d(Q);
  for (int i = (0); i < (Q); ++i) cin >> t[i] >> d[i];
  vector<int> golems(N, 1);
  for (int i = (0); i < (Q); ++i)
    for (int j = (0); j < (N); ++j) {
      if (s[j] == t[i]) {
        if (d[i] == 'L') {
          if (j == 0) {
            golems[j] = 0;
          } else {
            golems[j - 1] += golems[j];
            golems[j] = 0;
          }
        } else {
          if (j == N - 1) {
            golems[j] = 0;
          } else {
            golems[j + 1] += golems[j];
            golems[j] = 0;
          }
        }
      }
    }
  int ans = 0;
  for (int i = (0); i < (N); ++i) ans += golems[i];
  cout << ans << endl;
}
