#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<int> G(N, 1);
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    for (int j = 0; j < N; j++) {
      if (G[j] > 0 && S[j] == t) {
        if (d == 'L') {
          if (j > 0) {
            G[j - 1] += G[j];
          }
          G[j] = 0;
          continue;
        } else {
          if (j < N - 1) {
            G[j + 1] += G[j];
          }
          G[j] = 0;
          continue;
        }
      } else {
        continue;
      }
    }
  }
  int sum = 0;
  for (int i : G) {
    sum += i;
  }
  cout << sum << endl;
}
