#include <bits/stdc++.h>
using namespace std;
template <typename T0, typename T1>
std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) {
  for (typename map<T0, T1>::const_iterator p = v.begin(); p != v.end(); p++) {
    os << p->first << ": " << p->second << " ";
  }
  return os;
}
template <typename T0, typename T1>
std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) {
  os << v.first << ": " << v.second << " ";
  return os;
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const vector<T>& v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << " ";
  }
  return os;
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const set<T>& v) {
  vector<T> tmp(v.begin(), v.end());
  os << tmp;
  return os;
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const deque<T>& v) {
  vector<T> tmp(v.begin(), v.end());
  os << tmp;
  return os;
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const vector<vector<T>>& v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << endl;
  }
  return os;
}
template <typename T>
void maxUpdate(T& a, T b) {
  a = max(a, b);
}
template <typename T>
void minUpdate(T& a, T b) {
  a = min(a, b);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, Q;
  string S, T, D;
  while (cin >> N >> Q >> S) {
    vector<long long> w(N, 1);
    vector<long long> idx;
    for (int qi = 0, _n = (Q); (qi) < (int)_n; ++qi) {
      idx.clear();
      for (int i = 0, _n = (N); (i) < (int)_n; ++i)
        if (w[i]) idx.push_back(i);
      cin >> T >> D;
      long long ci = T[0] - 'A';
      for (int ii = 0, _n = (idx.size()); (ii) < (int)_n; ++ii) {
        long long i = idx[ii];
        if (T[0] == S[i]) {
          if (D[0] == 'L') {
            if (0 <= i - 1) w[i - 1] += w[i];
            w[i] = 0;
          }
          if (D[0] == 'R') {
            if (i + 1 < N) w[i + 1] += w[i];
            w[i] = 0;
          }
        }
      }
    }
    long long ans = accumulate((w).begin(), (w).end(), 0LL);
    cout << ans << endl;
  }
  return 0;
}
