#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
inline int safe_mul(const int x, const int y)
    __attribute__((warn_unused_result));
int const maxn = 200005;
int const CZ = 'Z' - 'A' + 1;
bitset<maxn> mask[CZ];
bitset<maxn> cur;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  for (int i = 0; i < n; ++i) {
    mask[s[i] - 'A'].set(i + 1);
  }
  cur[0] = true;
  cur[n + 1] = true;
  vector<string> qu;
  while (q--) {
    char s, t;
    cin >> s >> t;
    string tmp(1, s);
    tmp.push_back(t);
    qu.push_back(tmp);
  }
  reverse(qu.begin(), qu.end());
  for (const auto& s : qu)
    if (s[1] == 'R')
      cur |= (cur >> 1) & mask[s[0] - 'A'];
    else
      cur |= (cur << 1) & mask[s[0] - 'A'];
  cout << n - cur.count() + 2 << endl;
}
