#include <bits/stdc++.h>
using namespace std;
int sim(int i, string S, int N, int Q, int* dist, char td_list[Q][2]) {
  int idx = i;
  for (int j = 0; j < Q; ++j) {
    if (dist[i] != -2) return dist[i];
    if (idx == -1 || idx == N) {
      dist[i] = idx;
      return dist[i];
    }
    if (td_list[j][0] == S[idx]) {
      if (td_list[j][1] == 'L')
        idx--;
      else
        idx++;
    }
  }
  dist[i] = idx;
  return dist[i];
}
int main() {
  int N, Q;
  string S;
  cin >> N >> Q;
  cin >> S;
  char td_list[Q][2];
  for (int i = 0; i < Q; ++i) {
    cin >> td_list[i][0] >> td_list[i][1];
  }
  int dist[N];
  for (int i = 0; i < N; ++i) {
    dist[i] = -2;
  }
  int left = -1, right = N, mid;
  while (right - left != 1) {
    mid = (left + right) / 2;
    if (sim(mid, S, N, Q, dist, td_list) == -1) {
      left = mid;
    } else {
      right = mid;
    }
  }
  int lb = right;
  left = -1, right = N;
  while (right - left != 1) {
    mid = (left + right) / 2;
    if (sim(mid, S, N, Q, dist, td_list) == N) {
      right = mid;
    } else {
      left = mid;
    }
  }
  int rb = left;
  cout << rb - lb + 1 << endl;
  return 0;
}
