#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const long long INF = (long long)1e18 + 7;
long long dx[4] = {0, 1, 0, -1};
long long dy[4] = {1, 0, -1, 0};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<long long> T[26];
  vector<long long> ans(N, 1);
  for (long long i = 0; i < N; i++) {
    T[S[i] - 'A'].push_back(i);
  }
  for (long long i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    long long LR;
    if (d == 'L') {
      LR = -1;
    } else {
      LR = 1;
    }
    for (long long j = 0; j < T[t - 'A'].size(); j++) {
      long long p = T[t - 'A'][j] + LR;
      if (p >= N || p < 0) {
      } else {
        ans[p] += ans[T[t - 'A'][j]];
      }
      ans[T[t - 'A'][j]] = 0;
    }
  }
  long long cnt = 0;
  for (long long i = 0; i < N; i++) {
    cnt += ans[i];
  }
  cout << cnt << endl;
  return 0;
}
