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