#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, Q;
  string s, a, b;
  cin >> N >> Q >> s;
  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    x[i] = 1;
  }
  for (long i = 0; i < Q; i++) {
    cin >> a >> b;
    for (long j = 0; j < N; j++) {
      if (s[j] == 'a') {
        if (b == "L") {
          if (j != 0) {
            x[j - 1] += x[j];
            x[j] = 0;
          } else {
            x[j] = 0;
          }
        } else {
          if (j != N - 1) {
            x[j + 1] += x[j];
            x[j] = 0;
          } else {
            x[j] = 0;
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += x[i];
  }
  cout << ans;
  return 0;
}
