#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
inline void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
const long long INF = 1LL << 60;
long long N, Q;
char S[2 * 100001], t[2], d[2];
vector<long long> gorlm_num;
string SS, tt;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> Q;
  cin >> S;
  SS = S;
  for (int i = int(0); i < int(SS.size()); ++i) {
    gorlm_num.push_back(1);
  }
  for (int i = int(0); i < int(Q); ++i) {
    cin >> t >> d;
    tt = t;
    for (int j = int(0); j < int(SS.size()); ++j) {
      if (tt[0] == SS[j]) {
        long long tmp = gorlm_num[j];
        gorlm_num[j] = 0;
        if (strcmp(d, "R") == 0 && j != SS.size() - 1) {
          gorlm_num[j + 1] += tmp;
        }
        if (strcmp(d, "L") == 0 && j != 0) {
          gorlm_num[j - 1] += tmp;
        }
      }
    }
  }
  long long ans = 0;
  for (int i = int(0); i < int(gorlm_num.size()); ++i) {
    ans += gorlm_num[i];
  }
  cout << ans << endl;
  return 0;
}
