#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> t(Q), d(Q);
    for (int i = 0, _n = (Q); (i) < (int)_n; ++i) {
      cin >> T >> D;
      t[i] = T[0] - 'A';
      d[i] = D[0] == 'L';
    }
    vector<pair<long long, long long>> rn;
    long long lDone = 0, rDone = 0;
    for (int i = (int)(Q)-1; 0 <= (i); --i) {
      for (int j = 0, _n = (rn.size()); (j) < (int)_n; ++j) {
        if (0 <= rn[j].first - 1 && t[i] == S[rn[j].first - 1] - 'A' &&
            d[i] == 0)
          rn[j].first--;
        else if (rn[j].second + 1 < N && t[i] == S[rn[j].second + 1] - 'A' &&
                 d[i] == 1)
          rn[j].second++;
      }
      if (t[i] == S[0] - 'A' && d[i] == 1 && !lDone) {
        rn.push_back(make_pair(0, 0));
        lDone = 1;
      }
      if (t[i] == S[N - 1] - 'A' && d[i] == 0 && !rDone) {
        rn.push_back(make_pair(N - 1, N - 1));
        rDone = 1;
      }
    }
    vector<long long> w(N, 1);
    for (int qi = 0, _n = (Q); (qi) < (int)_n; ++qi) {
      for (int ri = 0, _n = (rn.size()); (ri) < (int)_n; ++ri) {
        for (int i = (int)rn[ri].first, _b = (int)(rn[ri].second + 1); (i) < _b;
             ++i) {
          if (t[qi] == S[i] - 'A') {
            if (d[qi] == 1) {
              if (0 <= i - 1) w[i - 1] += w[i];
              w[i] = 0;
            }
            if (d[qi] == 0) {
              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;
}
