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