#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string S;
  cin >> N >> Q;
  cin >> S;
  vector<vector<char>> v(Q, vector<char>(2));
  for (int i = 0; i < Q; i++) {
    cin >> v[i][0] >> v[i][1];
  }
  vector<int> pos(N, 1);
  for (int i = 0; i < Q; i++) {
    if (v[i][1] == 'L') {
      for (int j = 0; j < N; j++) {
        if (S[j] == v[i][0]) {
          if (j == 0) {
            pos[j] = 0;
          } else {
            pos[j - 1] += pos[j];
            pos[j] = 0;
          }
        }
      }
    } else {
      for (int j = N - 1; j >= 0; j--) {
        if (S[j] == v[i][0]) {
          if (j == N - 1) {
            pos[j] = 0;
          } else {
            pos[j + 1] += pos[j];
            pos[j] = 0;
          }
        }
      }
    }
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    count += pos[i];
  }
  cout << count << endl;
}
