#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int Q;
  cin >> N >> Q;
  int ans = N;
  vector<int> vec(N);
  string S;
  cin >> S;
  for (int i = 0; i < N; i++) {
    vec.at(i) = 1;
  }
  for (int i = 0; i < Q; i++) {
    char ti;
    char di;
    cin >> ti >> di;
    if ((S.at(0) == ti) & (di == 'L')) {
      ans = ans - vec.at(0);
      vec.at(0) = 0;
    }
    if ((S.at(0) == ti) & (di == 'R')) {
      vec.at(1) = (vec.at(1) + vec.at(0));
      vec.at(0) = 0;
    }
    if ((S.at(N - 1) == ti) & (di == 'R')) {
      ans = ans - vec.at(N - 1);
      vec.at(N - 1) = 0;
    }
    if ((S.at(N - 1) == ti) & (di == 'L')) {
      vec.at(N - 2) = (vec.at(N - 1) + vec.at(N - 2));
      vec.at(N - 1) = 0;
    }
    for (int j = 1; j < (N - 1); j++) {
      if ((S.at(j) == ti) & (di == 'R')) {
        vec.at(j + 1) = (vec.at(j + 1) + vec.at(j));
        vec.at(j) = 0;
      }
      if ((S.at(j) == ti) & (di == 'L')) {
        vec.at(j - 1) = (vec.at(j - 1) + vec.at(j));
        vec.at(j) = 0;
      }
    }
  }
  cout << ans << endl;
}
