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