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