#include <bits/stdc++.h>
using namespace std;
void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}
const int inf = INT_MAX / 2;
const long long infl = 1LL << 60;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int N, Q;
string S;
char T[201010], D[201010];
vector<int> query[26];
map<int, int> memo[201010];
int f(int i, int q) {
  if (memo[i].count(q)) return memo[i][q];
  if (Q == q) return 0;
  if (T[q] == S[i]) {
    if (D[q] == 'L' and i == 0) return memo[i][q] = 1;
    if (D[q] == 'R' and i == N - 1) return memo[i][q] = 1;
    if (D[q] == 'L')
      return memo[i][q] = f(i - 1, q + 1);
    else
      return memo[i][q] = f(i + 1, q + 1);
  }
  int nxt =
      upper_bound((query[S[i] - 'A']).begin(), (query[S[i] - 'A']).end(), q) -
      query[S[i] - 'A'].begin();
  if (query[S[i] - 'A'].size() == nxt) return memo[i][q] = 0;
  return memo[i][q] = f(i, query[S[i] - 'A'][nxt]);
}
void _main() {
  cin >> N >> Q >> S;
  for (int i = 0; i < Q; i++) cin >> T[i] >> D[i];
  for (int q = 0; q < Q; q++) query[T[q] - 'A'].push_back(q);
  int ans = N;
  for (int i = 0; i < N; i++)
    if (f(i, 0)) {
      ans--;
    }
  cout << ans << endl;
}
