#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, Q;
  string S;
  cin >> N >> Q;
  cin >> S;
  long A[N];
  for (long i = 0; i < N; i++) {
    A[i] = 1;
  }
  for (long i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    long x, y;
    if (d == 'L') {
      x = 1;
      y = 0;
    } else {
      x = -1;
      y = N - 1;
    }
    for (long j = y; 0 <= j && j < N; j += x) {
      if (S[j] == t) {
        int z = j - x;
        if (0 <= z && z < N) {
          A[z] += A[j];
        }
        A[j] = 0;
      }
    }
  }
  long ans = accumulate(A, A + N, 0);
  cout << ans << endl;
  return 0;
}
