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