#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> veca(Q);
  vector<char> vecb(Q);
  int anser = N;
  for (int i = 0; i < Q; i++) {
    cin >> veca.at(i) >> vecb.at(i);
  }
  for (int k = 0; k < N; k++) {
    int m = 0;
    m = k;
    vector<int> vecc(N);
    vecc.at(m) = 1;
    for (int j = 0; j < Q; j++) {
      if (s.at(m) == veca.at(j)) {
        if ((vecb.at(j) == 'R') && (vecc.at(N - 1) != 1)) {
          vecc.at(m) = 0;
          vecc.at(m + 1) = 1;
          m++;
        } else if ((vecb.at(j) == 'L') && (vecc.at(0) != 1)) {
          vecc.at(m) = 0;
          vecc.at(m - 1) = 1;
          m--;
        } else if ((vecb.at(j) == 'R') && (vecc.at(N - 1) == 1)) {
          anser--;
          break;
        } else if ((vecb.at(j) == 'L') && (vecc.at(0) == 1)) {
          anser--;
          break;
        }
      }
    }
  }
  cout << anser << endl;
}
