#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<vector<int>> cmap(26);
  vector<vector<int>> dp(Q + 1, vector<int>(N, 0));
  for (int i = 0; i < N; i++) {
    dp[0][i] = 1;
  }
  for (int i = 0; i < N; i++) {
    cmap[s[i] - 'A'].push_back(i);
  }
  for (int h = 1; h <= Q; h++) {
    char t, d;
    cin >> t >> d;
    for (int i = (d == 'L' ? 0 : N - 1);
         (d == 'L' && i < N) || (d == 'R' && i >= 0);
         i += (d == 'L' ? 1 : -1)) {
      if (find(cmap[t - 'A'].begin(), cmap[t - 'A'].end(), i) !=
          cmap[t - 'A'].end()) {
        dp[h][i] = 0;
        if (i > 0 && d == 'L') dp[h][i - 1] += dp[h - 1][i];
        if (i < N - 1 && d == 'R') dp[h][i + 1] += dp[h - 1][i];
      } else {
        dp[h][i] = dp[h - 1][i];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += dp[Q][i];
  }
  cout << ans << endl;
}
