#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template <typename T>
using VT = vector<T>;
template <typename T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const int MAX = 2e5 + 10;
int N, Q;
string S;
char t[MAX], d[MAX];
set<pair<int, int>> vis;
bool fall[MAX];
void dfs(int now, int idx) {
  if (vis.count(make_pair(now, idx))) {
    return;
  }
  vis.emplace(now, idx);
  if (idx == -1) {
    fall[now] = true;
    return;
  }
  const auto cur_t = t[idx];
  const auto cur_d = d[idx];
  if (cur_d == 'L' && now + 1 < N && S[now + 1] == cur_t) {
    dfs(now + 1, idx - 1);
  } else if (cur_d == 'R' && now > 0 && S[now - 1] == cur_t) {
    dfs(now - 1, idx - 1);
  }
  dfs(now, idx - 1);
}
int main(void) {
  cin >> N >> Q;
  cin >> S;
  for (int(i) = 0; (i) < (Q); (i)++) {
    string tmp;
    cin >> tmp;
    t[i] = tmp[0];
    cin >> tmp;
    d[i] = tmp[0];
  }
  for (int(i) = (Q)-1; (i) >= 0; (i)--) {
    if (t[i] == S[0] && d[i] == 'L') {
      dfs(0, i - 1);
    } else if (t[i] == S.back() && d[i] == 'R') {
      dfs(N - 1, i - 1);
    }
  }
  int cnt = 0;
  for (int(i) = 0; (i) < (N); (i)++) {
    cnt += fall[i];
  }
  cout << N - cnt << endl;
}
