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