#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q, count = 0;
  string S;
  char t, d;
  int M[200000];
  cin >> N >> Q >> S;
  count = N;
  for (int i = 0; i < N; i++) {
    M[i] = 1;
  }
  for (int i = 0; i < Q; i++) {
    cin >> t >> d;
    if (d == 'L') {
      if (S[0] == t) {
        count -= M[0];
        M[0] = 0;
      }
      for (int j = 1; j < N; j++) {
        if (S[j] == t) {
          M[j - 1] += M[j];
          M[j] = 0;
        }
      }
    } else {
      if (S[N - 1] == t) {
        count -= M[N - 1];
        M[N - 1] = 0;
      }
      for (int j = N - 2; j >= 0; j--) {
        if (S[j] == t) {
          M[j + 1] += M[j];
          M[j] = 0;
        }
      }
    }
  }
  cout << count;
}
