#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e15;
const long long int MOD = 1e9 + 7;
template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()) {
  return vector2<T>(n0, vector<T>(n1, e));
}
template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()) {
  return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int n, q;
  string s;
  cin >> n >> q >> s;
  vector<long long int> cnt(n, 1);
  vector<set<long long int>> a(26, set<long long int>());
  for (long long int i = 0; i < (n); ++i) {
    a[s[i] - 'A'].insert(i);
  }
  for (long long int i = 0; i < (q); ++i) {
    char t, d;
    cin >> t >> d;
    set<long long int> nxt;
    if (d == 'L') {
      for (auto it = a[t - 'A'].begin(); it != a[t - 'A'].end(); it++) {
        long long int id = *it;
        long long int tmp = cnt[id];
        cnt[id] = 0;
        if (id == 0) {
          continue;
        }
        if (cnt[id - 1] == 0) {
          if (s[id] == s[id - 1]) {
            nxt.insert(id - 1);
          } else {
            a[s[id - 1] - 'A'].insert(id - 1);
          }
        }
        cnt[id - 1] += tmp;
      }
    } else {
      for (auto it = a[t - 'A'].rbegin(); it != a[t - 'A'].rend(); it++) {
        long long int id = *it;
        long long int tmp = cnt[id];
        cnt[id] = 0;
        if (id == n - 1) {
          continue;
        }
        if (cnt[id + 1] == 0) {
          if (s[id] == s[id + 1]) {
            nxt.insert(id + 1);
          } else {
            a[s[id + 1] - 'A'].insert(id + 1);
          }
        }
        cnt[id + 1] += tmp;
      }
    }
    a[t - 'A'] = nxt;
  }
  long long int ans = 0;
  for (long long int i = 0; i < (n); ++i) {
    ans += cnt[i];
  }
  cout << ans << endl;
  return 0;
}
