#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  string T;
  string D;
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    T.push_back(t);
    D.push_back(d);
  }
  vector<vector<int>> dp(Q + 1, vector<int>(N));
  for (int i = 0; i < N; i++) {
    dp[0][i] = 1;
  }
  for (int i = 0; i < Q; i++) {
    for (int j = 0; j < N; j++) {
      dp[i + 1][j] += dp[i][j];
      if (T[i] == S[j]) {
        dp[i + 1][j] = 0;
      }
      if (j - 1 >= 0 && T[i] == S[j - 1] && D[i] == 'R') {
        dp[i + 1][j] += dp[i][j - 1];
      }
      if (j + 1 < N && T[i] == S[j + 1] && D[i] == 'L') {
        dp[i + 1][j] += dp[i][j + 1];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += dp[Q][i];
  }
  cout << ans << endl;
  return 0;
}
