#include <bits/stdc++.h>
int gholem[300000];
int gholemBuff[300000];
int main() {
  for (int k = 0; k < 300000; ++k) {
    gholem[k] = 1;
    gholemBuff[k] = 0;
  }
  int N, Q;
  std::string massMark;
  std::cin >> N >> Q;
  std::cin >> massMark;
  for (int i = 0; i < Q; ++i) {
    for (int k = 0; k < 300000; ++k) {
      gholemBuff[k] = 0;
    }
    char mark, orient;
    std::cin >> mark >> orient;
    for (int j = 0; j < N; ++j) {
      if (massMark[j] == mark) {
        if (orient == 'L') {
          gholemBuff[j] += gholem[j + 1];
          gholem[j + 1] = 0;
        } else if (orient == 'R') {
          gholemBuff[j + 2] += gholem[j + 1];
          gholem[j + 1] = 0;
        }
      }
    }
    for (int k = 0; k < N + 1; ++k) {
      gholem[k] += gholemBuff[k];
    }
  }
  int cnt = 0;
  for (int i = 1; i < N + 1; ++i) {
    cnt += gholem[i];
  }
  std::cout << cnt << std::endl;
  return 0;
}
