#include <bits/stdc++.h>
using namespace std;
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 gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int n, q;
string s;
vector<char> t, d;
int main() {
  cin >> n >> q >> s;
  t.resize(q);
  d.resize(q);
  for (int i = 0, temp = (int)(q); i < temp; ++i) cin >> t[i] >> d[i];
  vector<int> gorem(n, 1);
  unordered_map<char, vector<int> > graph;
  for (int i = 0, temp = (int)(n); i < temp; ++i) {
    char tem = s[i];
    graph[tem].push_back(i);
  }
  for (int i = 0, temp = (int)(q); i < temp; ++i) {
    char t_i = t[i];
    for (auto &pos : graph[t_i]) {
      int temp = gorem[pos];
      gorem[pos] = 0;
      if (d[i] == 'R') {
        if (pos + 1 < n) gorem[pos + 1] += temp;
      } else {
        if (pos > 0) gorem[pos - 1] += temp;
      }
    }
  }
  int ans = 0;
  for (int i = 0, temp = (int)(n); i < temp; ++i) ans += gorem[i];
  cout << ans << endl;
  return 0;
}
