#include <bits/stdc++.h>
using namespace std;
template <typename T>
void OutN(T x) {
  size_t i, len = x.size() - 1;
  for (i = 0; i < len; i++) cout << x[i] << " ";
  cout << x[len] << '\n';
}
template <typename T>
void Outit(T x) {
  auto end = x.end();
  end--;
  for (auto it = x.begin(); it != end; it++) cout << *it << " ";
  cout << *end << '\n';
}
template <typename T>
void Debug(const T &val) {
  cerr << val << '\n';
}
template <typename T, typename... Args>
void Debug(const T &val, Args... args) {
  cerr << val << ' ';
  Debug(std::forward<Args>(args)...);
}
template <typename T>
inline bool Max(T &x, const T &y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline bool Min(T &x, const T &y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
using V = vector<T>;
template <typename T>
using VV = V<V<T> >;
static const long long MOD = 1e9 + 7;
static const double PI = 3.141592653589793;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  map<char, V<long> > table;
  long go[n];
  long ans = 0;
  char t, d;
  long i, len;
  for ((i) = 0; (i) < (n); (i)++) {
    table[s[i]].push_back(i);
    go[i] = 1;
  }
  while (q--) {
    cin >> t >> d;
    len = table[t].size();
    if (d == 'L') {
      for ((i) = 0; (i) < (len); (i)++) {
        if (0 == table[t][i]) {
          go[table[t][i]] = 0;
        } else {
          go[table[t][i] - 1] += go[table[t][i]];
          go[table[t][i]] = 0;
        }
      }
    } else {
      for ((i) = 0; (i) < (len); (i)++) {
        if (n - 1 == table[t][i]) {
          go[table[t][i]] = 0;
        } else {
          go[table[t][i] + 1] += go[table[t][i]];
          go[table[t][i]] = 0;
        }
      }
    }
  }
  for ((i) = 0; (i) < (n); (i)++) ans += go[i];
  cout << (ans) << '\n';
  return 0;
}
